Merge pull request 'Change manual time formatting to dayjs time fomatting.' (#39) from dev into main
Reviewed-on: alekswilc/simrail-logs#39 Reviewed-by: Aleksander Wilczyński <aleks@alekswilc.dev>
This commit is contained in:
commit
f29c310cd3
@ -13,16 +13,8 @@ dayjs.locale(pl);
|
|||||||
export const msToTime = (duration: number, long = false) => {
|
export const msToTime = (duration: number, long = false) => {
|
||||||
const time = dayjs.duration(duration, 'milliseconds');
|
const time = dayjs.duration(duration, 'milliseconds');
|
||||||
|
|
||||||
if (long) {
|
if (long)
|
||||||
let t = '';
|
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(' ')})`;
|
||||||
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})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return time.humanize();
|
return time.humanize();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user