From 00d10a1649d301103fd1f25daa779f93d23ca9ae Mon Sep 17 00:00:00 2001 From: alekswilc Date: Mon, 26 Aug 2024 20:58:11 +0200 Subject: [PATCH 1/3] add days to time format --- src/util/time.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/time.ts b/src/util/time.ts index f622925..6b93a3e 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -15,10 +15,13 @@ export const msToTime = (duration: number, long = false) => { if (long) { let t = ''; + if (time.days()) t+= `${time.days()}d `; if (time.hours()) t+= `${time.hours()}h `; if (time.minutes()) t+= `${time.minutes()}m `; if (time.seconds()) t+= `${time.seconds()}s`; + if (!t) t = '1s'; + return `${time.humanize()} (${t})`; } -- 2.39.5 From 59e6bcfa8e28929a18fa168436875d41f3783966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Wilczy=C5=84ski?= Date: Tue, 27 Aug 2024 09:41:51 +0200 Subject: [PATCH 2/3] (ench): trim time, to avoid space before bracket. --- src/util/time.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/time.ts b/src/util/time.ts index e6ba92a..b297f8f 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -20,7 +20,7 @@ export const msToTime = (duration: number, long = false) => { if (time.minutes()) t+= `${time.minutes()}m `; if (time.seconds()) t+= `${time.seconds()}s`; - return `${time.humanize()} (${t})`; + return `${time.humanize()} (${t.trim() || "<1s"})`; } -- 2.39.5 From cb2e5ee557a0db857799ceef4ba6624a9238ff69 Mon Sep 17 00:00:00 2001 From: alekswilc Date: Tue, 27 Aug 2024 20:31:31 +0200 Subject: [PATCH 3/3] (ench): Change manual time formatting to dayjs time fomatting. See #38 --- src/util/time.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/util/time.ts b/src/util/time.ts index 6b93a3e..11ed332 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -13,18 +13,8 @@ dayjs.locale(pl); export const msToTime = (duration: number, long = false) => { const time = dayjs.duration(duration, 'milliseconds'); - if (long) { - let t = ''; - if (time.days()) t+= `${time.days()}d `; - if (time.hours()) t+= `${time.hours()}h `; - if (time.minutes()) t+= `${time.minutes()}m `; - if (time.seconds()) t+= `${time.seconds()}s`; - - if (!t) t = '1s'; - - return `${time.humanize()} (${t})`; - } - + if (long) + return `${time.humanize()} (${time.format('Y[y] M[mth] D[d] H[h] m[m] s[s]').split(' ').map(x => x.split('')[0] === '0' ? null : x).filter(x => x).join(' ')})`; return time.humanize(); } \ No newline at end of file -- 2.39.5