• 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: Donald Hall <email@hidden>
  • Date: Thu, 29 Nov 2007 23:33:02 -0700

Axel,

I have filed a bug for this. Apparently it was already a known issue as someone else had filed a prior bug report.

I modified my test script to use a fixed date. In this case when the script is run repeatedly the time of day continues to change with each run even though "__today" is a constant.

Don

At 8:40 AM -0800 11/29/07, email@hidden wrote:

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

-- Donald S. Hall, Ph.D. Apps & More Software Design, Inc. email@hidden http://www.appsandmore.com _______________________________________________ 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
  • Prev by Date: Re: Mail.app - Can't get contents of email with attachments
  • Next by Date: Re: Keeping a text-entry in the background, or a work-around
  • Previous by thread: Re: leopard date bug?
  • Next by thread: AppleScript & Alex Speech Synth
  • Index(es):
    • Date
    • Thread