Files
Athou_commafeed/commafeed-client/src/components/RelativeDate.tsx
2024-11-29 14:08:25 +01:00

18 lines
565 B
TypeScript

import { Trans } from "@lingui/react/macro"
import { Tooltip } from "@mantine/core"
import { Constants } from "app/constants"
import dayjs from "dayjs"
import { useNow } from "hooks/useNow"
export function RelativeDate(props: { date: Date | number | undefined }) {
const now = useNow(60 * 1000)
if (!props.date) return <Trans>N/A</Trans>
const date = dayjs(props.date)
return (
<Tooltip label={date.toDate().toLocaleString()} openDelay={Constants.tooltip.delay}>
<span>{date.from(dayjs(now))}</span>
</Tooltip>
)
}