Re: Date question with weeknumber
Re: Date question with weeknumber
- Subject: Re: Date question with weeknumber
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 3 May 2010 19:04:17 -0400
On Mon, May 3, 2010 at 5:53 PM, Nigel Garvey Among the other solutions, I particularly liked Mark's weekdayOnOrBefore
… although a greater proportion of integer arithmetic would be slightly
more efficient:
on weekdayOnOrBefore(aWeekDay, aDate)
return aDate - ((7 + (aDate's weekday) - aWeekDay) mod 7) * days
end weekdayOnOrBefore
Ah, yes. Thanks. I sloppily converted from a system where it could count in days directly; it's inefficient to do the multiplication twice.
-- In Snow Leopard, calculations using dates before
-- 1583 have been goodness-me'd by a shift to Julian dates before some
-- time in 1582.
set baseMonday to date "Monday 3 January 1583 00:00:00"
The first day of the Gregorian calendar, at least in those countries that adopted it immediately, was Friday, the 15th of October, 1582 (the previous day being Thursday the 4th according to the Julian calendar). So the first Gregorian Monday would be October 18th of that year. Of course, you could pick any Monday in the Julian calendar as well, but based on your comment above I infer that would not work on pre-SL systems.
I remain surprised the date of Julian/Gregorian conversion isn't locale-sensitive in Applescript, though.
--
Mark J. Reed <
email@hidden>
_______________________________________________
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