• 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
Issues subtracting Unix epoch from date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Issues subtracting Unix epoch from date
      • From: "Mark J. Reed" <email@hidden>
    • Re: Issues subtracting Unix epoch from date
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Simple simple... why so hard hard..?
  • Next by Date: Re: Issues subtracting Unix epoch from date
  • Previous by thread: Re: Simple simple... why so hard hard..?
  • Next by thread: Re: Issues subtracting Unix epoch from date
  • Index(es):
    • Date
    • Thread