Re: UNIX DATE
Re: UNIX DATE
- Subject: Re: UNIX DATE
- From: "Paul F. Henegan" <email@hidden>
- Date: Tue, 27 Apr 2004 15:52:55 -0400
on 24.04.2004 17:15, John Mistler at 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 ?
>
Hi John,
These two handlers are what I use. The "theFormattedTime" can be omitted if
the hours, minutes and seconds are not necessary.
on posixFormattedDate(theDate)
set CCYY to theDate's year as text
set MM to (("00" & (theDate's month as number as text))'s text items -2
thru -1 as text)--works with Panther
set dd to (("00" & (theDate's day as text))'s text items -2 thru -1 as
text)
set theFormattedTime to my posixFormattedTime(theDate)
set theFormattedDate to ("" & CCYY & MM & dd & theFormattedTime)
return theFormattedDate
end posixFormattedDate
on posixFormattedTime(theDate)
set asTimeString to theDate's time string
--do translation
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set posixTimeString to ("" & (asTimeString's text item 1) &
(asTimeString's text item 2) & "." & (asTimeString's text item 3))
set AppleScript's text item delimiters to oldTIDs
return posixTimeString
end posixFormattedTime
Peace,
paul
--
Paul F. Henegan
<email@hidden>
_______________________________________________
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>) |