Issues subtracting Unix epoch from date
Issues subtracting Unix epoch from date
- Subject: Issues subtracting Unix epoch from date
- From: Nathan Vander Wilt <email@hidden>
- Date: Sat, 20 Feb 2010 01:03:07 -0800
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)
By my understanding, this should give me (and any user) a reference date that corresponds to the Unix epoch. And it does show the right time when I add the output of a shell script 'date +%s' to unixEpoch. However, if I subtract the unixEpoch from a date during DST , the result is one hour off!
So when I run:
property unixEpoch : (date "Thursday, January 1, 1970 12:00:00 AM") + (time to GMT)
log unixEpoch + 1.266656406E+9
log (date "Saturday, June 30, 2007 5:05:00 PM") - unixEpoch
Script Editor logs:
(*date Saturday, February 20, 2010 1:00:06 AM*)
(*1.1832519E+9*)
This first date is the correct local time for 1266655998 Unix seconds. But 'date -r 1183251900' gives 6:05pm instead of 5:05pm:
Sat Jun 30 18:05:00 PDT 2007
How does AppleScript represent dates internally? What is happening to the second date calculation? How can I get it to work properly?
thanks,
-natevw _______________________________________________
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