• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Number of days since 1/1/0001
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Number of days since 1/1/0001


  • Subject: Re: Number of days since 1/1/0001
  • From: Nigel Garvey <email@hidden>
  • Date: Sat, 24 Nov 2001 12:39:12 +0000

ehsan saffari wrote on Fri, 23 Nov 2001 16:54:33 -0600:

>Given any date, I need to figure out the number of days that have passed
>since January 1, 0001, (730811 days for 23/11/2001)
>
>This should be easy with a simple date subtraction but AS simply refuses
>to accept a date with a year less than 1000.

Several people have already given goo replies to this. The AppleScript
Language Guide says: "More recent date and time utilities use a 64-bit
signed value that can represent dates from 30081 B.C. to 29940 A.D.
However, AppleScript currently will not handle dates before 1/1/1000 or
after 12/31/9999." (For non-US readers, that's 31st December 9999.)

The change from the Julian to the Gregorian calendar was to correct it in
the light of an improved understanding of the length of the solar year.
The calendar can therefore be assumed to be correct, even though older
dates were probably called something else at the time.

If you want the number of days from "1/1/1" to a date that can be
represented in AppleScript, the following would be a start:

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....

NG


  • Prev by Date: Re: Scripting Date and Time Control Panel
  • Next by Date: Re: Scripting Date and Time Control Panel
  • Previous by thread: Re: Number of days since 1/1/0001
  • Next by thread: Re: Number of days since 1/1/0001
  • Index(es):
    • Date
    • Thread