Re: Current date in standard additions dictionary
Re: Current date in standard additions dictionary
- Subject: Re: Current date in standard additions dictionary
- From: email@hidden
- Date: Sun, 3 Jun 2001 15:20:30 EDT
I was wanting a time_slug to be in 12 hour format. The applescript guide
gives the following subroutine for a time_slug in the format I want, but it
is in military time. Does anybody know how to convert to 12 hour format?
Thanks. John
set the time_slug to my format_time_using(the current date,":",{"H","MM"})
on format_time_using(this_date_record, delimiter_string, format_list)
set the time_index to the time of this_date_record
set the hour_index to ((the time_index) / hours) div 1
set the minute_index to ,
(((the time_index) / minutes) - (the hour_index * 60)) div 1
set the seconds_index to ,
((the time_index) - (the hour_index * 3600) - (the minute_index *
60)) div 1
set the formatted_time to ""
-- count the number of items in the list
set the item_count to the count of the format_list
-- parse the format list
repeat with i from 1 to the item_count
set this_item to item i of the format_list
if this_item is "H" then
set the formatted_time to ,
the formatted_time & the hour_index as string
else if this_item is "HH" then
if the hour_index is less than 10 then ,
set hour_index to ,
("0" & (the hour_index as string))
set the formatted_time to ,
the formatted_time & hour_index as string
else if this_item is "M" then
set the formatted_time to ,
the formatted_time & the minute_index as string
else if this_item is "MM" then
if the minute_index is less than 10 then ,
set minute_index to ,
("0" & (the minute_index as string))
set the formatted_time to ,
the formatted_time & minute_index as string
else if this_item is "S" then
set the formatted_time to ,
the formated_time & the seconds_index as string
else if this_item is "SS" then
if the seconds_index is less than 10 then ,
set seconds_index to ,
("0" & (the seconds_index as string))
set the formatted_time to ,
the formatted_time & seconds_index as string
end if
if i is not the item_count then
-- add delimiter
set the formatted_time to ,
the formatted_time & delimiter_string as string
end if
end repeat
return the formatted_time
end format_time_using