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