2023-12-19 08:52:25 +00:00
|
|
|
import { Duration } from 'luxon';
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
const FormatMillisecond = ({ time }: { time: number }) => {
|
|
|
|
const formatTime = Duration.fromMillis(time)
|
|
|
|
.shiftTo('days', 'hours', 'minutes', 'seconds')
|
|
|
|
.toObject();
|
2023-12-19 10:24:15 +00:00
|
|
|
|
2023-12-19 08:52:25 +00:00
|
|
|
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;
|