Re: re: Issues subtracting Unix epoch from date
Re: re: Issues subtracting Unix epoch from date
- Subject: Re: re: Issues subtracting Unix epoch from date
- From: "Mark J. Reed" <email@hidden>
- Date: Sun, 21 Feb 2010 16:30:23 -0500
On Sun, Feb 21, 2010 at 4:19 PM, Nigel Garvey
<email@hidden> wrote:
>>property perlTime : "perl -MTime::Local -MPOSIX -e 'print
>>strftime(\"%m/%d/%y
>>%I:%M:%S %p\"
> Obviously the local time zone in this case is somewhere between Pacific/
> Honolulu and US/Eastern. :)
Good point. The above Perl code is not portable because the strftime
format has to match your locale settings in order for AppleScript to
parse it properly.
The below is more portable.
property perlTime : "perl -MTime::Local -le 'print join(qq(
), localtime timegm @ARGV)' "
on GMT2localtime(yr, mon, dy, hr, min, sec)
set argList to {}
repeat with arg in {sec, min, hr, dy, (mon as integer) - 1, (yr as
integer) - 1900}
set end of argList to quoted form of (arg as text)
end repeat
set text item delimiters to space
set {sec, min, hr, dy, mon, yr} to paragraphs of (do shell script
(perlTime & (argList as text)))
set returnDate to current date
set returnDate's year to (yr as integer) + 1900
set returnDate's day to 1
set returnDate's month to (mon as integer) + 1
set returnDate's day to dy
set returnDate's hours to hr
set returnDate's minutes to min
set returnDate's seconds to sec
return returnDate
end GMT2localtime
GMT2localtime(2010, 2, 22, 16, 26, 53)
--
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