OK this is almost totally off-topic - apologies I wouldn't abuse this 
list if I didn't think you all would appreciate this
if you haven't already read it, namely Stanley Rabinowitz's 1983 
response to the VMS bug report:

The LIB$DAY Run-Time Library service incorrectly  assumes  the  year 2000 is a 
leap year


http://h71000.www7.hp.com/openvms/products/year-2000/leap.html<http://www-users.cs.york.ac.uk/susan/joke/decly.htm>

-Mike

On 6/16/2011 7:38 PM, Jason Hunter wrote:
> If you don't care about holidays, it's pretty easy to do it 
> efficiently.  Just count the days and do a little edge checking to 
> decide how many were weekends.  You don't even have to consider leap 
> year logic because that's included in the day count.
>
> Just don't let the time span cross year 1582.  ;)
>
> There's other oddities too.  For example, from 
> http://en.wikipedia.org/wiki/Gregorian_calendar:
>
> "In Alaska, the change took place when Friday, 6 October 1867 was 
> followed again by Friday, 18 October after the US purchase of Alaska 
> from Russia, which was still on the Julian calendar. Instead of 12 
> days, only 11 were skipped, and the day of the week was repeated on 
> successive days, because the International Date Line was shifted from 
> Alaska's eastern to western boundary along with the change to the 
> Gregorian calendar."
>
> Good luck.  ;)
>
> -jh-
>
> On Jun 16, 2011, at 4:04 PM, [email protected] 
> <mailto:[email protected]> wrote:
>
>> I guess the only way is to loop through all the dates and check their 
>> day of week. I was hoping there was something slicker, but it doesn't 
>> look like it.
>>
>> Thanks Geert. that's some fine code there.
>>
>> -Ryan
>>
>> ------------------------------------------------------------------------
>> From:[email protected] <mailto:[email protected]>
>> To:[email protected] 
>> <mailto:[email protected]>
>> Date: Thu, 16 Jun 2011 08:36:04 +0200
>> Subject: Re: [MarkLogic Dev General] Net Working Days calculation?
>>
>> Hi Ryan,
>>
>> Fun question! Hadn’t done it yet, but that doesn’t matter. How about 
>> this? It returns a list of all workable days. Wrap in a count to get 
>> a number. Perhaps not the fastest/smartest solution, but it should 
>> get you going..
>>
>> import module namespace functx = "http://www.functx.com"; at 
>> "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
>>
>> let $holidays := (xs:date("2011-06-13")) (: second easter day:)
>>
>> let $start := xs:date("2011-06-09")
>> let $end := xs:date("2011-06-16")
>>
>> return
>>     for $day in (0 to days-from-duration($end - $start))
>>     let $date := $start + xs:dayTimeDuration(concat("P",$day,"D"))
>>     let $weekday := functx:day-of-week($date)
>>     let $is-weekend := ($weekday = (0, 6))
>>     let $is-holiday := exists(index-of($date, $holidays))
>>     where not($is-weekend) and not($is-holiday)
>>     return
>>         $date
>>
>> Kind regards,
>> Geert
>>
>> *Van:*[email protected] 
>> <mailto:[email protected]>[mailto:[email protected]]*Namens*[email protected]
>>  
>> <mailto:[email protected]>
>> *Verzonden:*donderdag 16 juni 2011 0:32
>> *Aan:*[email protected] 
>> <mailto:[email protected]>
>> *Onderwerp:*[MarkLogic Dev General] Net Working Days calculation?
>>
>> Has anyone done a Net Working Days calculation in XQuery? This would 
>> be the number of business days between a start and end date.Holiday 
>> inclusion would be awesome.
>>
>> -Ryan
>>
>> _______________________________________________ General mailing 
>> [email protected] 
>> <mailto:[email protected]>http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> [email protected] <mailto:[email protected]>
>> http://developer.marklogic.com/mailman/listinfo/general
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to