Re: Correcting AGE_INFO
Re: Correcting AGE_INFO
>>>That's demonstrably correct, but as I said, inefficient. So the goal is to achieve the same results without having to iterate
over all the days in between.
Not sure if that's always a worthy goal.
The difference in efficiency is pretty minor. Plus a solution that iterates is pretty easily modified to include a list of dates that should be excluded for holidays, and such, if needed. (I can't imagine a practical use where that's not needed).
ES
------------
property holidayList : {}
set holidayList to {"12/25/09", "1/1/10", "7/4/10"} -- user can add more dates
repeat with x from 1 to count of holidayList
set item x of holidayList to date (item x of holidayList)
end repeat
set startDate to date ("11 - 20 - 2009")
set endDate to date ("1 - 2 - 2010")
set BD to CountBusinessDays(startDate, endDate)
on CountBusinessDays(aDate, endDate)
set dayCount to 0
repeat until aDate > endDate
if aDate is not in holidayList and weekday of aDate is not in {Saturday, Sunday} then set dayCount to dayCount + 1
set aDate to (aDate + 1 * days)
end repeat
return dayCount
end CountBusinessDays
-------------
On Feb 5, 2010, at 11:20am, Mark J. Reed wrote:
> That's demonstrably correct, but as I said, inefficient.
> So the goal is to achieve the same results without having to iterate
> over all the days in between.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden