diff options
| author | Jules Laplace <jules@okfoc.us> | 2013-01-24 15:33:23 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2013-01-24 15:33:23 -0500 |
| commit | c15f0f8f6127554f5ddf05718de568c7d3a7dbc5 (patch) | |
| tree | 0f9f4b39a28f302242e75c24c9f38c5acdd55f4f /public/javascripts/util.js | |
| parent | 45aeb76d1d199e31d6cf33eafe34092c7dfc68cc (diff) | |
idling yourself
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 |
