Re: Number of days since 1/1/0001
Re: Number of days since 1/1/0001
- Subject: Re: Number of days since 1/1/0001
- From: Nigel Garvey <email@hidden>
- Date: Mon, 26 Nov 2001 00:40:43 +0000
Nigel Garvey wrote on Sat, 24 Nov 2001 12:39:12 +0000:
>
Several people have already given goo replies to this.
"Good" ones too. ;-)
>
on daysSinceDot(theDate)
>
set aSolarYear to 365 * days + 5 * hours + 48 * minutes + 46
>
set aMillennium to aSolarYear * 1000
>
((theDate - (date "Thursday, 1 January 1001 00:00:00")) +
>
aMillennium) div days
>
end daysSinceDot
>
>
daysSinceDot(date "Friday, 23 November 2001 00:00:00")
>
--> 730811
>
>
However, if you set aMillennium to (date "Monday, 1 January 2001
>
00:00:00") - (date "Thursday, 1 January 1001 00:00:00"), the end result
>
is 730812. Unfortunately, I don't have time to investigate this this
>
morning....
The reason for the difference seems to be that - as a quick AppleScript
test shows - the even-numbered calendar millennia AD (ie. 2nd, 4th, 6th,
etc.) contain one day more than do the odd-numbered ones. The number of
days in my (solar year * 1000) millennium happens to round down to the
number of days in the first millennium AD (1 - 1000), and thus gives the
correct result. The millennium encompassed by the AppleScript date
subtraction is the second (1001 - 2000), which is a day longer, thus
introducing a spurious extra day into the result. I should have used the
third millennium instead:
set aMillennium to (date "Thursday, 1 January 3001 00:00:00") - (date
"Monday, 1 January 2001 00:00:00")
For those interested in such trivia, odd-numbered AD millennia (and
Gregorian cycles) always begin on a Thursday and even-numbered ones
always on a Monday.
NG