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: Nigel Garvey <email@hidden>
- Date: Thu, 22 Feb 2001 21:26:54 +0000
"Arthur J Knapp" wrote on Thu, 22 Feb 2001 11:10:23 -0500:
>
> Subject: Re: Has the 5th business day of the month passed???
>
> Date: Thu, 22 Feb 2001 00:20:40 +0000
>
> From: Nigel Garvey <email@hidden>
>
> tell (current date) to set fifthBusinessDay to its day > 7 or (its day
>
>> 5 and its weekday is Saturday) or (its day is 7 and its weekday is
>
Sunday)
>
I kid you not, this is the best single line of AppleScript
>
code I have ever seen. It's clean, clear, efficient, and not
>
at all obfuscated. :)
Thanks. :-) It's not often that circumstances warrant such a beast.
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. In theory, you add
1 to the 7's and the 5 in the existing line, but it's actually more
convenient to subtract 1 from the day of the date instead. The comparison
works out the same in the end. Unfortunately, a further adjustment is
also needed to avoid possible mistaken identity during the weekend
following a holiday. I *think* this now works in all situations:
tell (current date)
if its month is in {January, July, August} then
if its weekday is in {Saturday, Sunday, Monday} then
set dayNum to (its day) - 3 -- holiday adjustment at weekend
else
set dayNum to (its day) - 1 -- holiday adjustment otherwise
end if
else
set dayNum to its day -- normal setting
end if
set fifthBusinessDay to dayNum > 7 or (dayNum > 5 and its weekday is
Saturday) or (dayNum is 7 and its weekday is Sunday)
end tell
NG