OK so you want to make this challanging do ya. ;)

How about creating a table that has the holiday name, country, rule for
determining when the holiday occurs, and a code snippet that calculates the
date for a given year. Sort of a rules based artificial intelligence system.

For example:
HolidayName     Christmas
Country All
Rule            Dec 25
Code            <@assign method$thisHoliday value="@@method$year/12/25">

HolidayName     Thanksgiving
Country Canada
Rule            2nd Monday in October
Code            <@assign method$oct1st <@format str="@@method$year/10/01"
format="datetime:%w">>
                <@if expr="@@method$oct1st=0"><@assign method$thisHoliday
value="@@method$year/10/09">
                <@elseif expr="@@method$oct1st=1"><@assign method$thisHoliday
value="@@method$year/10/08">
                <@elseif expr="@@method$oct1st=2"><@assign method$thisHoliday
value="@@method$year/10/14">
                <@elseif expr="@@method$oct1st=3"><@assign method$thisHoliday
value="@@method$year/10/13">
                <@elseif expr="@@method$oct1st=4"><@assign method$thisHoliday
value="@@method$year/10/12">
                <@elseif expr="@@method$oct1st=5"><@assign method$thisHoliday
value="@@method$year/10/11">
                <@elseif expr="@@method$oct1st=6"><@assign method$thisHoliday
value="@@method$year/10/10">
                </@if>

Then you can make a method that takes input parameters of date and country.
Select all the holidays where country=all or country=@@method$country. Set
returnValue to 0 (or false). Loop through the code snippets and evaluate
each using the year of the input date. If a holiday date matches the input
date set returnValue to 1 (or true).

Of course if you have a many to many relationship between holidays and
countries you can define that in the database too.

You may have to reformat the dates to match your sys$dateFormat, because not
everyone uses the same date format.

If you get a lot of holiday searches and performance becomes an issue, you
could populate a domain or application scope array with all the holidays in
a certain timeframe, then just compare your date against that array.

Dave.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Anthony M. Humphreys
Sent: Thursday, December 12, 2002 8:21 AM
To: Multiple recipients of list witango-talk
Subject: Re: Witango-Talk: Holiday Calculator



Not quite, I was hoping to find the piece of code that would know if a given
date is/is not a holiday.

Some holidays, like Christmas, are easy, they always occur on the same day
each year.
Some are almost easy, they occur on the x day of a month.
Some, like Easter/Good Friday, are somewhat complicated to calculate.

Has anyone written Tango/Witango or JavaScript code to calculate holidays,
not to look them up from a DBMS?
Would you be willing to share with me/with the list?

Anthony -


----- Original Message -----
From: "David Shelley" <[EMAIL PROTECTED]>
To: "Multiple recipients of list witango-talk" <[EMAIL PROTECTED]>
Sent: Thursday, December 12, 2002 00:41
Subject: RE: Witango-Talk: Holiday Calculator


> Hi Anthony,
>
> I assume you want to find X business days from a certain date. I wrote
> something like that once. You still need to keep track of holidays in a
> table or array though. Here's the pseudo code. I'm sure you can write it
in
> Witango tags. :)
>
> populate an array of holidays
> counter = 0
> endDate = startDate
> for 1 to some arbitrary high number (an @while tag would be nice here)
>    if counter >= # of days then break
>    endDate = endDate +  1 day
>    if endDate is not Saturday or Sunday and not in holiday array then
> increment counter
> /for
>
> You can easily put it in a method, pass it the startDate and #of days, and
> have it return the endDate.
>
> Is that what you were looking for?
>
> Dave Shelley
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Anthony M. Humphreys
> Sent: Wednesday, December 11, 2002 7:48 PM
> To: Multiple recipients of list witango-talk
> Subject: Witango-Talk: Holiday Calculator
>
>
> Does anyone have a Tango/Witango or JavaScript Holiday calculator that
they
> are willing to share?
>
> I know about this:
> http://gethelp.devx.com/techtips/thesqlpro/10min/10min0201/10min0201.asp
> ..but this is a bit too clumsy for my purposes.
>
> I was hoping for a program that can calculate holidays, not a brute force
> method where I have to add all the dates and holidays into a table before
> hand.
>
> Anyone got some ideas?
>
> Anthony -
>
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>                 with unsubscribe witango-talk in the message body
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>                 with unsubscribe witango-talk in the message body

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to