Broken date math on AppleScript 2.0
Broken date math on AppleScript 2.0
- Subject: Broken date math on AppleScript 2.0
- From: Scott Babcock <email@hidden>
- Date: Fri, 15 Feb 2008 16:25:43 -0800
- Acceptlanguage: en-US
- Thread-topic: Broken date math on AppleScript 2.0
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.
_______________________________________________
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