From c15f0f8f6127554f5ddf05718de568c7d3a7dbc5 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 24 Jan 2013 15:33:23 -0500 Subject: idling yourself --- public/javascripts/util.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'public/javascripts/util.js') 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 -- cgit v1.2.3-70-g09d2