• 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: UNIX DATE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UNIX DATE


  • Subject: Re: UNIX DATE
  • From: Paul Berkowitz <email@hidden>
  • Date: Sat, 24 Apr 2004 16:33:22 -0700

On 4/24/04 2:15 PM, "John Mistler" <email@hidden> wrote:

> Is there a simple way to convert an applescript date such as:
>
> date Friday, December 24, 2004 3:00:00 PM
>
> to
>
> a UNIX format such as
>
> 2004-12-24 15:00:00
>
> or
>
> 20041224150000 ?


set s to ((date "Friday, December 24, 2004 3:00:00 PM") - (date "Thursday,
January 1, 1970 12:00:00 AM"))
set s to my Stringify(s)
do shell script "date -ur " & s & " \"+ %F %T\""
--> "2004-12-24 15:00:00"



to Stringify(X) -- for E+ numbers
set X to X as string
set {tids, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {"E+"}}
if (count (text items of X)) = 1 then
set AppleScript's text item delimiters to {tids}
return X
else
set {n, z} to {text item 1 of X, (text item 2 of X) as integer}
set AppleScript's text item delimiters to {tids}
set i to character 1 of n
set decSepChar to character 2 of n -- "." or ","
set d to text 3 thru -1 of n
set l to count d
if l > z then
return (i & (text 1 thru z of d) & decSepChar & (text (z + 1)
thru -1 of d)) -- one line
else
repeat (z - l) times
set d to d & "0"
end repeat
return (i & d)
end if
end if
end Stringify




--
Paul Berkowitz

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >UNIX DATE (From: John Mistler <email@hidden>)

  • Prev by Date: UNIX DATE
  • Next by Date: Re:Identifying special characters
  • Previous by thread: UNIX DATE
  • Next by thread: Re: UNIX DATE
  • Index(es):
    • Date
    • Thread