Created
April 25, 2016 20:07
-
-
Save ceme/a8d6717d170c65c734f768e1cdd08ea4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @param Number timecode (milliseconds) | |
* @return String h:m:s (zero padded to two spaces) | |
* Usage: timecodeDisplay(11282000) -> "03:08:02" | |
*/ | |
function timecodeDisplay(timecode) { | |
var seconds = timecode / 1000 % 60; | |
var secondsDisp = (seconds <= 9) ? '0' + seconds : '' + seconds; | |
var minutes = (((timecode / 1000) - seconds) / 60) % 60; | |
var minutesDisp = (minutes <= 9) ? '0' + minutes : '' + minutes; | |
var hours = ((((timecode / 1000) - seconds) / 60) - minutes) / 60; | |
var hoursDisp = (hours <= 9) ? '0' + hours : '' + hours; | |
return hoursDisp + ':' + minutesDisp + ':' + secondsDisp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment