• 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 21:55:18 +0000

"Mark J. Reed" wrote on Sun, 21 Feb 2010 16:30:23 -0500:

>>>property perlTime : "perl -MTime::Local -MPOSIX -e 'print
>>>strftime(\"%m/%d/%y
>>>%I:%M:%S %p\"

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

--> date "Monday 22 February 2010 16:26:53" on my machine.  :)  But then
I live in an outdated time zone.  ;)

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

  • Follow-Ups:
    • Re: Issues subtracting Unix epoch from date
      • From: Doug McNutt <email@hidden>
References: 
 >Re: re: Issues subtracting Unix epoch from date (From: "Nigel Garvey" <email@hidden>)
 >Re: re: Issues subtracting Unix epoch from date (From: "Mark J. Reed" <email@hidden>)

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