import { Duration } from 'luxon'; import React, { ComponentPropsWithoutRef } from 'react'; import { cn } from 'utils/classnames'; export interface FormatMilliSecondProps extends ComponentPropsWithoutRef<'div'> { time: number; } const FormatMillisecond = ({ time, ...props }: FormatMilliSecondProps) => { const formatTime = Duration.fromMillis(time) .shiftTo('days', 'hours', 'minutes', 'seconds') .toObject(); return (
{formatTime.days !== 0 && {formatTime.days}d } {formatTime.hours !== 0 && {formatTime.hours}h } {formatTime.minutes !== 0 && {formatTime.minutes}m } {formatTime.seconds}s
); }; export default FormatMillisecond;