• 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: leopard date bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: leopard date bug?


  • Subject: Re: leopard date bug?
  • From: Axel Luttgens <email@hidden>
  • Date: Thu, 29 Nov 2007 16:38:50 +0100

On 26/11/07 7:31, Donald Hall wrote:

Can anyone explain this? Looks like a serious bug to me (note differing results for 18, 20, and 100 years in the future):

Test script
---------------------------------------------------------------------------


set __today to (current date)

[...]

set newDate to __today + 17 * 365.25 * days
log newDate

set newDate to __today + 18 * 365.25 * days
log newDate

[...]
-------------------------------------------------
End of test script

Leopard (10.5.0) result:
--------------------------------------------------

tell current application
    current date
        date "Sunday, November 25, 2007 11:17:29 PM"
    [...]
    (*Monday, November 25, 2024 5:17:29 AM*)
    (*Friday, September 18, 2009 12:46:20 AM*)
    [...]
end tell


Tiger result: --------------------------------------------------- tell current application current date date "Sunday, November 25, 2007 11:24:21 PM" [...] (*Monday, November 25, 2024 5:24:21 AM*) (*Tuesday, November 25, 2025 11:24:21 AM*) [...] end tell


Looks like to be related to some spurious coercion occuring when the time offset (in seconds) exceeds the largest integer that can be expressed in AppleScript.
Let's try this one:


   set CD to current date
   log CD

   -- Note: 536870909 seconds is a bit more than 17 years.
   repeat with i from 0 to 4
       log "---- " & i & " ----"
       log 536870909 + i
       log CD + (536870909 + i)            -- [*]
       log (CD + (536870909 + i)) - CD
   end repeat

As soon as i reaches 3, (536870909 + i) is converted into a real, and those strange results are then issued from line [*].

Note that the substraction of dates doesn't seem to be affected, as it may return results bigger than the largest integer (as of line [+]):

   set CD to current date
   log CD

   repeat with i from 0 to 4
       log "---- " & i & " ----"
       log 536870909 + i
       log (CD + 536870909) + i
       log ((CD + 536870909) + i) - CD     -- [+]
   end repeat

Such an asymetric behavior indeed smells like a bug.
(same behavior on both Intel and PPC)

On the other hand, the ASLG states:

   AppleScript supports these operations with the + and - operators
   on date and time difference values:
       date + timeDifference
       --result: date
       date - date
       --result: timeDifference
       date - timeDifference
       --result: date

   where date is a date value and timeDifference is an integer value
   specifying a time difference in seconds.

and I couldn't find a later release note explicitely extending the range of timeDifference beyond integers.


Axel




_______________________________________________ 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
References: 
 >leopard date bug? (From: Donald Hall <email@hidden>)

  • Prev by Date: Idea for better handling of mailinglists
  • Next by Date: force quit
  • Previous by thread: leopard date bug?
  • Next by thread: Re: leopard date bug?
  • Index(es):
    • Date
    • Thread