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

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 18:04:20 -0500

On Sat, Feb 20, 2010 at 5:51 PM, Nathan Vander Wilt
<email@hidden> wrote:
> The way the calculations are done does matter! How many seconds are there between the Unix epoch and 2007-June-30 17:05:00 PDT?

Well, 1,183,248,323, but POSIX doesn't bother to count the 23 of them
that were leap seconds

> AppleScript:
> property unixEpoch : (date "Thursday, January 1, 1970 12:00:00 AM") + (time to GMT)
> log (date "Saturday, June 30, 2007 5:05:00 PM") - unixEpoch
> --> (*1.1832519E+9*)
>
> Cocoa:
> NSDate* date = [NSDate dateWithNaturalLanguageString:@"Saturday, June 30, 2007 5:05:00 PM"];
> printf("%f\n", [date timeIntervalSince1970]);
> --> 1183248300.000000
>
> So AppleScript says 1183251900 seconds, while Cocoa gives the correct answer of 1183248300 seconds.

So when interpreting the date string, it looks like AppleScript is
internally converting it to a POSIX timestamp using the current value
of (time to GMT).  That is . . . unfortunate.

--
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

  • Follow-Ups:
    • Re: Issues subtracting Unix epoch from date
      • From: Nathan Vander Wilt <email@hidden>
References: 
 >Issues subtracting Unix epoch from date (From: Nathan Vander Wilt <email@hidden>)
 >Re: Issues subtracting Unix epoch from date (From: "Mark J. Reed" <email@hidden>)
 >Re: Issues subtracting Unix epoch from date (From: Nathan Vander Wilt <email@hidden>)
 >Re: Issues subtracting Unix epoch from date (From: "Mark J. Reed" <email@hidden>)
 >Re: Issues subtracting Unix epoch from date (From: Nathan Vander Wilt <email@hidden>)

  • Prev by Date: Re: Issues subtracting Unix epoch from date
  • Next by Date: Re: Issues subtracting Unix epoch from date
  • Previous by thread: Re: Issues subtracting Unix epoch from date
  • Next by thread: Re: Issues subtracting Unix epoch from date
  • Index(es):
    • Date
    • Thread