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: Chris Nebel <email@hidden>
- Date: Sat, 24 Nov 2001 21:34:10 -0800
- Organization: Apple Computer, Inc.
ehsan saffari wrote:
>
No matter how non-trivial, when subtracting a date ahead of the boundry
>
from a date behind the boundry AS does it without any fuss. It just can't
>
be done with a simple subtraction with dates below 1/1/1000.
>
>
The workaround is to reinvent the wheel and calculate the number of days,
>
which the Mac OS already knows but does not expose.
The date subtraction works cleanly (for some definition of "works cleanly")
because AppleScript -- or, more precisely, the Date and Time Utilities
package it uses -- punts on the whole Gregorian/Julian mess and takes the
simple way out: it uses the modern calendar as a reference point and works
backward from there. This means that what AppleScript tells you the weekday
of, say, October 14, 1066 was might differ from what someone there at the
time would have told you, but hey, it's a solution.
The problem here isn't that AppleScript doesn't know about dates before 1000
AD, but rather that the date parser (which AppleScript doesn't control)
doesn't think that's what you mean. It's biased towards modern dates, so if
you give a year of "1" or "01", you get 2001, which is probably for the
best. (Irritatingly, you get 2001 even if you say "0001" -- you might think
that many leading zeros would be enough to get its attention.) The simplest
way I can find to get a date of 1/1/0001 is this:
set x to date "1/1"
set year of x to 1 --> date "Monday, January 1, 0001 12:00:00 AM"
--Chris