From 080643e89af62013d70bb574cd54cf4876628515 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 11 Aug 2013 20:36:10 +0200 Subject: improved account list --- pyload/web/app/scripts/helpers/formatTime.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'pyload/web/app/scripts/helpers/formatTime.js') 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); -- cgit v1.2.3