diff options
Diffstat (limited to 'pyload/web/app/scripts/helpers/formatTime.js')
-rw-r--r-- | pyload/web/app/scripts/helpers/formatTime.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/pyload/web/app/scripts/helpers/formatTime.js b/pyload/web/app/scripts/helpers/formatTime.js index 757ff73ad..0fb0f6058 100644 --- a/pyload/web/app/scripts/helpers/formatTime.js +++ b/pyload/web/app/scripts/helpers/formatTime.js @@ -1,15 +1,18 @@ -// Format bytes in human readable format -define('helpers/formatTime', ['handlebars', 'vendor/remaining'], function(Handlebars, Remaining) { +// Formats a timestamp +define('helpers/formatTime', ['underscore','handlebars', 'moment', 'utils/i18n'], + function(_, Handlebars, moment, i18n) { 'use strict'; - function formatTime(seconds, options) { - if (seconds === Infinity) - return '∞'; - else if (!seconds || seconds <= 0) - return '-'; + function formatTime(time, format) { + if (time === -1) + return i18n.gettext('unkown'); + else if (time === -2) + return i18n.gettext('unlimited'); - // TODO: digital or written string - return Remaining.getStringDigital(seconds, window.dates); + if (!_.isString(format)) + format = 'lll'; + + return moment(time).format(format); } Handlebars.registerHelper('formatTime', formatTime); |