diff options
Diffstat (limited to 'public/javascripts/util.js')
| -rw-r--r-- | public/javascripts/util.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/public/javascripts/util.js b/public/javascripts/util.js index cd1e0c9..86c8328 100644 --- a/public/javascripts/util.js +++ b/public/javascripts/util.js @@ -30,4 +30,32 @@ function timeInWords (time) { if (seconds[1].length == 1) seconds[1] = seconds[1] + "0"; str.push( pluralize( seconds[0] + "." + seconds[1], "second" ) ); return str.join(", "); +} + +function timeInSecs (time) { + var str = []; + time /= 1000; + if (time > 86400) { + str.push( leading( time / 86400 ) ); + } + if (time > 3600) { + str.push( leading( (time / 3600) % 24 ) ); + } + if (time > 60) { + str.push( leading( (time / 60) % 60 ) ); + } + str.push( leading( time % 60 ) ); + +/* + var seconds = Math.floor(10 * (time % 60)) / 10; + seconds = (seconds + "").split("."); + if (seconds.length == 1) seconds[1] = "0"; + str.push( leading( time % 60 ) + "." + seconds[1] ); +*/ + + return str.join(":"); +} +function leading(num) { + num = Math.floor(num); + return num < 10 ? "0" + num : num; }
\ No newline at end of file |
