diff --git a/src/util/time.ts b/src/util/time.ts index e6ba92a..11ed332 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -13,16 +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`; - - 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