- Code: Select all
set militaryTime to value of variable "sprk_Start_Time"
set standardTime to militaryTimeToStandardTime(militaryTime)
on militaryTimeToStandardTime(militaryTime)
set militaryTime to militaryTime as text
if length of militaryTime is equal to 4 then
set theHour to text 1 thru 2 of militaryTime
set theMinutes to text 3 thru 4 of militaryTime
else if length of militaryTime is equal to 3 then
set theHour to "" & text 1 of militaryTime
set theMinutes to text 2 thru 3 of militaryTime
else if length of militaryTime is equal to 2 then
set theHour to "00"
set theMinutes to text 1 thru 2 of militaryTime
else if length of militaryTime is equal to 1 then
set theHour to "00"
set theMinutes to "0" & text 1 of militaryTime
end if
set theHourNumber to theHour as number
if (theHourNumber is equal to 0) and (theMinutes is equal to 0) then
set standardTime to "12:00 AM"
else if theHourNumber is greater than 12 then
set theHourNumber to theHourNumber - 12
set standardTime to (theHourNumber as text) & ":" & theMinutes & " pm"
else if theHourNumber = 12 then
set standardTime to theHour & ":" & theMinutes & " pm"
else if (theHourNumber is equal to 0) and (theMinutes is not equal to 0) then
set standardTime to "12" & ":" & theMinutes & " am"
else
set standardTime to theHour & ":" & theMinutes & " am"
end if
end militaryTimeToStandardTime
set value of variable "sprk_Start_Time_AmPm" to standardTime
Very much appreciate any help with it.
Thanks,
Carl