Very strange dates - BUG
Very strange dates - BUG
- Subject: Very strange dates - BUG
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 29 Jan 2003 09:40:06 -0800
What exactly happened on Wednesday, January 19, 1972 3:14:08 AM? Did time
reverse direction?
From that moment on, you can do this:
set thedate to date "Wednesday, January 19, 1972 3:14:08 AM"
set thedate to thedate + (-1)
--> date "Wednesday, January 19, 1972 3:14:07 AM"
But move it back one second or more:
set thedate to date "Wednesday, January 19, 1972 3:14:07 AM"
set thedate to thedate + (-1)
--> date "Saturday, December 12, 1835 8:45:50 PM"
Similarly:
set thedate to date "1/1/1971"
set thedate to thedate + (-1)
-->date "Monday, November 24, 1834 5:31:43 PM"
This comes up when you need to add (time to GMT), which may be a negative
integer. Where I am, in PST,
time to GMT
--> -28800
(date "1/1/1971") + (time to GMT)
--> date "Monday, November 24, 1834 9:31:44 AM"
Hmmm.
Since subtracting positive integers works OK for all dates (at least after
1/1/1904), this is the workaround:
set timeToGMT to (time to GMT)
if timeToGMT < 0 then
set theDate to theDate - (-timeToGMT)
else
set theDate to theDate + (timeToGMT)
end if
Shouldn't AppleScript be able to do the same thing? Convert addition of a
signed negative integer to subtraction of an unsigned integer (or signed
positive integer, if that's what it's doing)?
For an even more absurd, related, bug, see the next post.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.