• 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: "Nigel Garvey" <email@hidden>
  • Date: Sun, 21 Feb 2010 09:53:35 +0000

I wrote on Sat, 20 Feb 2010 20:34:11 +0000:

>"Mark J. Reed" wrote on Sat, 20 Feb 2010 09:42:59 -0500:
>
>> 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.
>
>  (* Convert an ISO-format date string to an AppleScript date. *)
>  on isotToDate(isot)
>    set theDate to date "Monday 25 November 1000 00:00:00"
>    set n to (text 1 thru 8 of isot) as integer
>    set theDate's year to n div 10000
>    set theDate's month to (n mod 10000 div 100)
>    set theDate's day to n mod 100

Apologies for the idiosyncratic start date above, which I forgot to
rationalise before I posted. The script was originally written to be
compatible with my Jaguar system, which doesn't do months-as-integer.
The start date was "Monday 1 December 1000 00:00:00", the year was set
to the derived year - 1, the day then was set to the derived month
number * 32 and then set again to the derived day number.

  1. Opening the script on my SL machine decompiled the start date to
the Julian calendar.
  2. The day-overflow technique no longer gives reliable results.

I modernised the date setting sequence, but neglected the start date. In
fact any date with a day number < 29 is OK now.

[snip]

>  on epochTime(GMTDate)
>    return GMTDate - (date "Saturday 1 January 1972 00:00:00")
>  end epochTime

And that of course was plain wrong. <blush>

  on epochTime(GMTDate)
    return GMTDate - (date "Thursday 1 January 1970 00:00:00")
  end epochTime

I think everything else is OK.

>  -- Perl code by Mark J. Reed.
>  set myTZ to (do shell script "perl -le 'print( readlink(\"/etc/
>localtime\") =~m{zoneinfo/(.*)} )' ")
>
>  set arbitraryLocalDate to date "Saturday 30 June 2007 05:05:00"
>  set epochSeconds to epochTime(TZtoGMT(arbitraryLocalDate, myTZ))

NG

 _______________________________________________
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

  • 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