Re: Broken date math on AppleScript 2.0
Re: Broken date math on AppleScript 2.0
- Subject: Re: Broken date math on AppleScript 2.0
- From: Philip Aker <email@hidden>
- Date: Fri, 15 Feb 2008 20:31:42 -0800
On 2008-02-15, at 16:25:43, Scott Babcock wrote:
It appears that date math on AppleScript 2.0 (shipped with Leopard)
is not working correctly with large values.
If you have an integer whose value exceeds 0x1FFFFFFF, and you try
to add or subtract this integer from a date, you will not get the
expected value.
This integer equates to 17 years, 3 weeks, 4 days, 18 hours, 31
seconds. (This assumes 52 weeks in a year - leap years are not
considered).
Further pathology: The bogus value you get is processor-dependant.
Even further pathology: The time component of the bogus result
changes with every run.
set now to date "Friday, February 15, 2008 3:07:35 PM"
set sub to (2 ^ 29) - 1 --> 5.36870911E+8
set den to (now - sub)
--> date "Sunday, February 10, 1991 8:19:04 PM"
set sub to sub + 1 --> 5.36870912E+8
set den to (now - sub)
--> Intel: date "Thursday, June 16, 2005 6:55:28 PM" (or so...)
--> PPC: date "Tuesday, January 22, 2008 9:48:30 PM" (or so...)
I opened a bug for this. We'll see how soon Apple can produce a fix.
Thanks a lot for mentioning this Scott. I'll be watching for it at C
level and let you know if it's reproducible there.
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
_______________________________________________
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