With the help of David's Pseudo Code I wrote this
functionality in Witango. It creates an array of
holidays then loops through each date checking to see
if its a holiday or a Saturday or a Sunday - If a
holiday falls on a Saturday or Sunday it is not added
as it is included in the first part....

Here is the code.....

<@! create array of holidays>
<@ASSIGN request$holidays <@ARRAY
VALUE="02/13/2002;02/24/2002;02/26/2002" CDELIM=","
RDELIM=";">>

<@assign request$date2 value="2002-02-27">
<@assign request$date1 value="2002-02-10">
<@assign request$date value="@@request$date1">
<@assign request$numdays value="<@DATEDIFF
DATE1=@@request$date2 DATE2=@@request$date1
[FORMAT=%d/%m/%y]>">

<@FOR START="1" STEP="1" STOP="@@request$numdays">
        
        <@assign request$date value="<@DAYS
DATE=@@request$date DAYS=1>">
        <@assign request$dayno value="<@var request$date
format=datetime:%w>">

        <@! check is it a holiday>
        <@if '<@FILTER ARRAY="holidays" scope=request
EXPR="#1=@@request$date">'>
                <@assign request$counter value="<@calc
'@@request$counter+1'>">
        </@if>
        
        <@! check is it a saturday or sunday and not a
holiday>
        <@if '@@request$dayno=0 || @@request$dayno=6 '>
                <@if '<@FILTER ARRAY="holidays" scope=request
EXPR="#1=@@request$date">'>
                <@else> 
                <@assign request$counter value="<@calc
'@@request$counter+1'>">
                </@if>
        </@if>
</@FOR>

There are @@request$counter holidays between
@@request$date1 and @@request$date2



<@! end of code>

let me know if it works ok for you....

--- David Shelley <[EMAIL PROTECTED]> wrote:
> 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


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to