Player Duration to hh:mm:ss
Garrett Hylltun
garretthylltun at gmail.com
Mon Dec 19 17:13:03 EST 2005
This is exactly what I wanted to do! Thanks :-)
-Garrett
On Dec 19, 2005, at 11:40 AM, Bill Marriott wrote:
> There is no built-in function, but the custom function below (place
> it in
> the stack script) should get you started:
>
> ===================================
>
> function ConvertSeconds mySecondsTime
>
> if isNumber(mySecondsTime) then
>
> -- 3600 seconds in an hour
> put the trunc of (mySecondsTime / 3600) into myHours
> if myHours < 10 then put "0" before myHours -- leading zero
>
> -- 60 seconds in a minute
> put the trunc of ((mySecondsTime - (3600 * myHours)) / 60) into
> myMinutes
> if myMinutes < 10 then put "0" before MyMinutes -- leading zero
>
> -- the remainder is seconds
> put mySecondsTime - 3600 * myHours - 60 * myMinutes into mySeconds
> if mySeconds < 10 then put "0" before MySeconds -- leading zero
> return myHours & ":" & myMinutes & ":" & mySeconds
>
> else
>
> return "Error: ConvertSeconds() requires a number"
>
> end if
>
> end ConvertSeconds
>
> ===================================
>
>> From this you can use ConvertSeconds(number) from any handler in
>> the stack
> to get the result you want.
>
> Example:
>
> ConvertSeconds(60) returns "00:01:00"
> ConvertSeconds(121.5) returns "00:02:01.5"
>
> - Bill
[snip]
More information about the use-livecode
mailing list