Re: Has the 5th business day of the month passed???
Re: Has the 5th business day of the month passed???
- Subject: Re: Has the 5th business day of the month passed???
- From: email@hidden
- Date: Thu, 22 Feb 2001 22:50:50 -0500
On Thu, 22 Feb 2001 21:26:54 +0000, Nigel Garvey <email@hidden>
asked,
>
Of course, it doesn't make allowances for public holidays. For this, you
>
need to make an adjustment in months that have (one!) public holiday in
>
their first five business days. From the list in Jason's revised script,
>
these look to be January, July, and August in the US.
I had some work that required my scripts to deal with working days and holidays,
so I wrote a script object that understands them.
Memorial Day in the US is challenging to code correctly, because it is the last
Monday in May. But I was able to cover it, and all the other floating holidays,
with a data structure: I created a list of "ordinals" that represent these
holidays. An ordinal is a list like this: { 3, Monday, January } for Martin
Luther King Day, the third Monday in January. I then calculate a date in
question's ordinal as
{ ((day of testDate) -1 ) div 7 + 1, weekday of testDate, month of testDate }
and use "is in" to see if its in the holiday list. For Memorial Day, I use
AppleScript's convention that item -1 is the last item, -2 is the
second-to-last, etc. I represent Memorial Day as { -1, Monday, May} and
calculate a negative ordinal
{ (( day of (lastDateInMonth for testDate))- (day of testDate))div -7 - 1,
...
With this package, testing if the fifth business day has past becomes
property WorkingDays: load script alias "Where:ever:Working Days"
set firstOfMonth to current date
set day of firstOfMonth to 1
tell WorkingDays
if (workingTime from firstOfMonth to current date) > 5 * (its dailyTime)
then
--- Five business days have passed
I've posted this script object on my web site at
http://www.tidalwave.net/~snorton/
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden