diff options
Diffstat (limited to 'pyload/web/app/scripts/helpers/formatTime.js')
-rw-r--r-- | pyload/web/app/scripts/helpers/formatTime.js | 20 |
1 files changed, 20 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..750ce58fe --- /dev/null +++ b/pyload/web/app/scripts/helpers/formatTime.js @@ -0,0 +1,20 @@ +// Formats a timestamp +define('helpers/formatTime', ['underscore','handlebars', 'moment', 'utils/i18n'], + function(_, Handlebars, moment, i18n) { + 'use strict'; + + function formatTime(time, format) { + if (time === -1) + return i18n.gettext('unknown'); + else if (time === -2) + return i18n.gettext('unlimited'); + + if (!_.isString(format)) + format = 'lll'; + + return moment(time).format(format); + } + + Handlebars.registerHelper('formatTime', formatTime); + return formatTime; +}); |