diff options
Diffstat (limited to 'pyload/web/app/scripts/helpers/formatTimeLeft.js')
-rw-r--r-- | pyload/web/app/scripts/helpers/formatTimeLeft.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pyload/web/app/scripts/helpers/formatTimeLeft.js b/pyload/web/app/scripts/helpers/formatTimeLeft.js new file mode 100644 index 000000000..dafeda3e2 --- /dev/null +++ b/pyload/web/app/scripts/helpers/formatTimeLeft.js @@ -0,0 +1,17 @@ +// Format seconds in human readable format +define('helpers/formatTimeLeft', ['handlebars', 'vendor/remaining'], function(Handlebars, Remaining) { + 'use strict'; + + function formatTimeLeft(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('formatTimeLeft', formatTimeLeft); + return formatTimeLeft; +});
\ No newline at end of file |