summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/helpers/formatTime.js
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/helpers/formatTime.js')
-rw-r--r--pyload/web/app/scripts/helpers/formatTime.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/pyload/web/app/scripts/helpers/formatTime.js b/pyload/web/app/scripts/helpers/formatTime.js
new file mode 100644
index 000000000..757ff73ad
--- /dev/null
+++ b/pyload/web/app/scripts/helpers/formatTime.js
@@ -0,0 +1,17 @@
+// Format bytes in human readable format
+define('helpers/formatTime', ['handlebars', 'vendor/remaining'], function(Handlebars, Remaining) {
+ 'use strict';
+
+ function formatTime(seconds, options) {
+ if (seconds === Infinity)
+ return '∞';
+ else if (!seconds || seconds <= 0)
+ return '-';
+
+ // TODO: digital or written string
+ return Remaining.getStringDigital(seconds, window.dates);
+ }
+
+ Handlebars.registerHelper('formatTime', formatTime);
+ return formatTime;
+}); \ No newline at end of file