Re: time formatting
Re: time formatting
- Subject: Re: time formatting
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 28 Jun 2007 16:38:35 -0400
It sounds like you want to convert from 12-hour (am/pm) time to
24-hour time. That's not "universal" - "Universal Time" means
Greenwich mean time (pace a few technical quibbles).
IIRC, most of the date formatting posts have already had a time value
recognized as such by AppleScript. What you have is a text string you
want to reformat. You could parse it into a date value and then
format that appropriately, but it would seem to be easier to just fix
the string.
I'm typing this on my phone (hence the tofu, sorry, no option in GMail
Mobile) and can't really code, but I would use text item delimiters to
split the string into fields, further split the time into
hour/minute/second fields, look at the am/pm field, and if it's "PM",
add 12 to the hour. Then put the time back together without the
colons and put the whole string back with the new time in place.
On 6/28/07, cheshirekat <email@hidden> wrote:
I've been reading a lot of date formatting posts hoping this had already
been discussed (and saved by me) on this list, but have come up empty.
If this has already come up, it would save me from reinventing the wheel.
I am pulling events from a specific iCal calendar to a text document for
my iPod. When done, I have events that have strings of
Wednesday 6/27/07 from 11:00:00 AM to 4:00:00 PM
I would like to have universal times of
Wednesday 6/27/07 from 1100 to 1600
Here is the relevant part of the script:
repeat with ev in eventTargets
set the evProps to the ev's properties
set the evStartDate to (the short date string of (the
evProps's start date))
set the evDay to word 1 of (the date string of (the
evProps's start date))
set the evStartTime to (the time string of (the evProps's
start date))
--> 11:00:00 AM
-- need to change time to universal format
set the evEndTime to (the time string of (the evProps's
end date))
--> 4:00:00 PM
-- need to change time to universal format
-- sp = " ", ret = return
set the evData to evDay & sp & evStartDate & " from " &
evStartTime & " to " & evEndTime & ret
set the gardenEvents to (the gardenEvents & the evData)
end repeat
Thanks for the help.
--
"I never before knew the full value of trees. Under them I breakfast,
dine, write, read and receive my company."
- Thomas Jefferson
* Mac Pro 2 GHz Quad Xeon * OS X 10.4.10 * 3 GB RAM *
_______________________________________________
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
--
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