Pass 2 times with am or pm extensions. The result will be the difference in time. Use hh:mm:ss am/pm format.
Reproduced with permission from Penworks Lingo User"s Journal
on timeDifference startTime, endTime
set twelveHourAdditive =hmsToFrames("12:00:00",1,0,0)
-- First account for any PM hours by adding twelve
set startTimeAdditive =0
if startTime contains "PM" then
set startTimeAdditive =twelveHourAdditive
end if
set endTimeAdditive =0
if (endTime contains "PM") then
set endTimeAdditive =twelveHourAdditive
end if
-- Now adjust for any hours starting with 12
if (startTime starts "12:") then
set startTimeAdditive =startTimeAdditive - twelveHourAdditive
end if
if (endTime starts "12:") then
set endTimeAdditive =endTimeAdditive - twelveHourAdditive
end if
-- Now remove the AM/PM stuff
set spaceLoc =offset(" ",startTime)
set startTime =char 1 to (spaceLoc - 1) of startTime
set spaceLoc =offset(" ", endTime)
set endTime =char 1 to (spaceLoc -1) of endTime
-- Now convert to frames
set startFrames =hmsToFrames(startTime, 1, 0, 0)
set startFrames =startFrames + startTimeAdditive
set endFrames =hmsToFrames(endTime, 1, 0, 0)
set endFrames =endFrames + endTimeAdditive
-- Now make sure we didn"t wrap around midnight
if endFrames < startFrames then
set endFrames =endFrames + (twelveHourAdditive * 2)
end if
-- Calculate the difference in frames, and convert back
set difference =endFrames - startFrames
set elapsedTime =framesToHms(difference, 1, 0, 0)
return(elapsedTime)
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA