Player Duration to hh:mm:ss

Cubist at aol.com Cubist at aol.com
Tue Dec 20 05:22:46 EST 2005


   Although Bill Marriott's function works fine, it struck me as being 
somewhat inelegant, not to mention longer than necessary. Here's my version of the 
function in question; for you newbies, my code makes use of the numberFormat 
property, and the div (integer division) and mod (the remainder of an integer 
division) functions.

function Sec2HMS TheTime # TheTime is measured in seconds
  # Automagically take care of leading zeroes as needed
  set the numberFormat to "00"

  # How many hours is that?
  put TheTime div 3600 into TheHours
  put TheTime mod 3600 into TheTime

  # How many minutes?
  put TheTime div 60 into TheMinutes

  # How many seconds?
  put TheTime mod 60 into TheSeconds

  # We got yer result right here...
  return TheHours & ":" & TheMinutes & ":" & TheSeconds
end Sec2HMS



More information about the use-livecode mailing list