subroutine ConvertTimeAMPM (string: Time) is
integer Hours
string AMPM
HoursString
MinutesString
extract from Time
take to ":" HoursString
skip ":"
take to ":" MinutesString
copy HoursString to Hours
if (Hours > 12) then
copy (Hours - 12) to Hours
copy Hours to HoursString
copy " PM" to AMPM
else
copy " AM" to AMPM
end if
copy HoursString ":" MinutesString AMPM to Time