Re: Issues subtracting Unix epoch from date
Re: Issues subtracting Unix epoch from date
- Subject: Re: Issues subtracting Unix epoch from date
- From: "Mark J. Reed" <email@hidden>
- Date: Sat, 20 Feb 2010 09:42:59 -0500
On Sat, Feb 20, 2010 at 4:03 AM, Nathan Vander Wilt
<email@hidden> wrote:
> My AppleScript code needs to send and receive dates from another utility, and passing them as seconds from the Unix epoch seems like it should be the most reliable. To achieve this, I set the following property at the top of my script:
>
> property unixEpoch : (date "Thursday, January 1, 1970 12:00:00 AM") + (time to GMT)
Hm. Apart from the outdated time zone designation "GMT", the function
"time to GMT" is poorly named; I'd expect, from the name, that it's
what you add to local time to get GMT, but in fact it's what you add
to GMT to get local time. But never mind.
The problem is that (time to GMT) returns the offset as of *now*, when
the script is run. That's different from the offset at the time in
question, because in June, Daylight Saving Time is in effect. That's
the source of your 1-hour discrepancy. You need something that will
tell you the offset to UTC as of an arbitrary date, not just as of
now. Which is a hard thing to do, given the way the DST rules have
shifted over time and space.
--
Mark J. Reed <email@hidden>
_______________________________________________
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