MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Paul Berkowitz <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sun, 25 May 2003 09:17:09 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
On 5/25/03 8:59 AM, "Nigel Garvey" <[log in to unmask]>
wrote:

>>  copy theDate to b
>>  set b's month to January
>>  1 - (b - 1 - theDate) div (28 * days)
>
> It works with every date I've tested so far in the AppleScript date
> range, including those that come before 1904. Because of a Mac OS
> date-subtraction bug, French Vanilla crashes on dates before 1904. (I
> know what you're thinking, but it's a vulnerability nonetheless.)
>
> It turns out that the bug doesn't kick in when a later date is subtracted
> from an earlier one, so English Fudge subtracts the January date from the
> original instead of vice versa. Since the two dates are exactly the same
> when the original date's in January, one second is subtracted from the
> 'January' date to ensure a later-from-earlier subtraction. (This works
> even when the intermediate result is outside the official AppleScript
> date range.) The result of the 'div' is then *subtracted* from the first
> '1' in the line to cancel out the negatives.

I came upon a date (and large number) addition-of-a-negative-number bug,
which could put you back a whole Mac epoch (c. 136 years) so you found
yourself in the 1800's instead of 1972. In that case subtraction of positive
numbers was the solution. What's the subtraction bug exactly?

BTW, do you actually meant the opposite of what you say here:

> It turns out that the bug doesn't kick in when a later date is subtracted
> from an earlier one, so English Fudge subtracts the January date from the
> original instead of vice versa.

Won't the January date be _earlier_ than the original one, so don't you want
to subtract the original date from the January one, not vice versa, if you
want a later-from-earlier? And is there really a bug with subtracting a
number from itself - not getting 0 - if the dates are exactly the same in
the case of original dates in January? You still need to subtract 1 to get
an earlier January date?

--
Paul Berkowitz

ATOM RSS1 RSS2