You would think this could be done in Excel, but Excel gives inaccurate results when adding segment times. I have tried different time formats in Excel but no joy.
Suggestions welcome.
Code: Select all
Global time$,seconds
Procedure ToSeconds(time$)
seconds=Val(StringField(time$,1,":")) *60 ;CONVERT MINUTES TO SECONDS
seconds+Val(StringField(time$,2,":"))
;Debug seconds
EndProcedure
Procedure FormatTimestr(seconds)
;mins = Val(StringField(time$,1,":"))
mins = Int(seconds / 60)
secs = seconds - (mins * 60)
If secs < 10: sec$ = "0" + Str(secs) ;PAD WITH LEADING 0
Else
sec$ = Str(secs)
EndIf
If mins > 0 ;DROP LEADING 0
Debug Str(mins) + ":" + sec$
Else
Debug ":" + sec$
EndIf
EndProcedure
;ToSeconds ("1:30")
FormatTimestr(121)