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

Re: Broken date math on AppleScript 2.0


  • Subject: Re: Broken date math on AppleScript 2.0
  • From: deivy petrescu <email@hidden>
  • Date: Mon, 18 Feb 2008 18:41:50 -0500


On Feb 15, 2008, at 19:25, 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.

I do not know if it is date or integer problem. This also have a bug:

set now to (current date)
set sub to ((2 ^ 12) + 2117.783697) * days
--sub is approximately 17 years
set den to (now - sub)
--->date "Wednesday, February 13, 1991 23:46:52"

Which seems right. But go to

set now to (current date)
set sub to ((2 ^ 12) + 2117.783698) * days
--note 8  instead of 7 in the last digit
set den to (now - sub)
--->date "Saturday, September 8, 2007 8:48:28"

Nothing to do with rounding:

set now to (current date)
set sub to ((2 ^ 12) + 2118) * days
set den to (now - sub)
--->date "Saturday, September 8, 2007 8:54:16"


Is this a "different bug" ?


Deivy _______________________________________________ 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: "Mark J. Reed" <email@hidden>
References: 
 >Broken date math on AppleScript 2.0 (From: Scott Babcock <email@hidden>)

  • Prev by Date: Spotlight comments - command line?
  • Next by Date: Re: Dynamically change button cell image within a table view
  • Previous by thread: Re: Broken date math on AppleScript 2.0
  • Next by thread: Re: Broken date math on AppleScript 2.0
  • Index(es):
    • Date
    • Thread