20 lines
576 B
TypeScript
20 lines
576 B
TypeScript
import { Duration } from 'luxon';
|
|
import React from 'react';
|
|
|
|
const FormatMillisecond = ({ time }: { time: number }) => {
|
|
const formatTime = Duration.fromMillis(time)
|
|
.shiftTo('days', 'hours', 'minutes', 'seconds')
|
|
.toObject();
|
|
|
|
return (
|
|
<div>
|
|
{formatTime.days !== 0 && <span>{formatTime.days}d </span>}
|
|
{formatTime.hours !== 0 && <span>{formatTime.hours}h </span>}
|
|
{formatTime.minutes !== 0 && <span>{formatTime.minutes}m </span>}
|
|
<span>{formatTime.seconds}s</span>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default FormatMillisecond;
|