summaryrefslogtreecommitdiff
path: root/public/javascripts/util.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2013-01-24 15:33:23 -0500
committerJules Laplace <jules@okfoc.us>2013-01-24 15:33:23 -0500
commitc15f0f8f6127554f5ddf05718de568c7d3a7dbc5 (patch)
tree0f9f4b39a28f302242e75c24c9f38c5acdd55f4f /public/javascripts/util.js
parent45aeb76d1d199e31d6cf33eafe34092c7dfc68cc (diff)
idling yourself
Diffstat (limited to 'public/javascripts/util.js')
-rw-r--r--public/javascripts/util.js28
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