From e8363781af1b41a137c0ac936cea51933c9d1353 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 7 Dec 2023 17:38:13 +0100 Subject: [PATCH] [web] Remove leading zero in time representations --- web-src/src/filter/index.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/web-src/src/filter/index.js b/web-src/src/filter/index.js index 3bcf07afdc..b1e951a74e 100644 --- a/web-src/src/filter/index.js +++ b/web-src/src/filter/index.js @@ -5,15 +5,8 @@ const { t, locale } = i18n.global export const filters = { durationInHours(value_ms) { - const seconds = Math.floor(value_ms / 1000) - if (seconds > 3600) { - return Duration.fromObject({ seconds }) - .shiftTo('hours', 'minutes', 'seconds') - .toFormat('hh:mm:ss') - } - return Duration.fromObject({ seconds }) - .shiftTo('minutes', 'seconds') - .toFormat('mm:ss') + const format = value_ms >= 3600000 ? 'h:mm:ss' : 'm:ss' + return Duration.fromMillis(value_ms).toFormat(format) }, durationInDays(value_ms) { @@ -44,7 +37,6 @@ export const filters = { timeFromNow(value) { const diff = DateTime.now().diff(DateTime.fromISO(value)) - return this.durationInDays(diff.as('milliseconds')) },