summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/helpers/formatTime.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-11 20:20:27 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-11 20:20:27 +0100
commit7a3e656a9d202471c323540826ceb1f7145db781 (patch)
tree8541a0fd2d9394ad6c5ab78189a039a27706ba33 /module/web/static/js/helpers/formatTime.js
parentwebsocket login via session, websocket pushes server status, webui renders se... (diff)
downloadpyload-7a3e656a9d202471c323540826ceb1f7145db781.tar.xz
better time formatting
Diffstat (limited to 'module/web/static/js/helpers/formatTime.js')
-rw-r--r--module/web/static/js/helpers/formatTime.js29
1 files changed, 3 insertions, 26 deletions
diff --git a/module/web/static/js/helpers/formatTime.js b/module/web/static/js/helpers/formatTime.js
index cb635ede9..77d67a39c 100644
--- a/module/web/static/js/helpers/formatTime.js
+++ b/module/web/static/js/helpers/formatTime.js
@@ -1,29 +1,5 @@
// Format bytes in human readable format
-define('helpers/formatTime', ['handlebars'], function(Handlebars) {
-
- // TODO: seconds are language dependant
- // time could be better formatted
- function seconds2time (seconds) {
- var hours = Math.floor(seconds / 3600);
- var minutes = Math.floor((seconds - (hours * 3600)) / 60);
- seconds = seconds - (hours * 3600) - (minutes * 60);
- var time = "";
-
- if (hours != 0) {
- time = hours+":";
- }
- if (minutes != 0 || time !== "") {
- minutes = (minutes < 10 && time !== "") ? "0"+minutes : String(minutes);
- time += minutes+":";
- }
- if (time === "") {
- time = seconds+"s";
- }
- else {
- time += (seconds < 10) ? "0"+seconds : String(seconds);
- }
- return time;
- }
+define('helpers/formatTime', ['handlebars', 'utils/remaining'], function(Handlebars, Remaining) {
function formatTime(seconds, options) {
@@ -32,7 +8,8 @@ define('helpers/formatTime', ['handlebars'], function(Handlebars) {
else if (!seconds || seconds <= 0)
return "-";
- return seconds2time(seconds);
+ // TODO: digital or written string
+ return Remaining.getStringDigital(seconds, window.dates);
}
Handlebars.registerHelper('formatTime', formatTime);