• 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
Broken date math on AppleScript 2.0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Broken date math on AppleScript 2.0
      • From: deivy petrescu <email@hidden>
    • Re: Broken date math on AppleScript 2.0
      • From: Philip Aker <email@hidden>
    • Re: Broken date math on AppleScript 2.0
      • From: Doug McNutt <email@hidden>
  • Prev by Date: Re: Run AppleScript in the background (hide window)
  • Next by Date: Re: Coercing strings to symbols
  • Previous by thread: Re: Coercing strings to symbols
  • Next by thread: Re: Broken date math on AppleScript 2.0
  • Index(es):
    • Date
    • Thread