mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-24 07:34:23 +00:00
24 lines
No EOL
457 B
TypeScript
24 lines
No EOL
457 B
TypeScript
import { useTranslation } from "next-i18next"
|
|
|
|
type HumanDateProps = {
|
|
date: Date
|
|
}
|
|
|
|
|
|
export function HumanDate({date}: HumanDateProps) {
|
|
const {t} = useTranslation()
|
|
|
|
if(Number.isNaN(date.getTime())) {
|
|
return (
|
|
<span className="disabled">
|
|
{t("dateNaN")}
|
|
</span>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<time dateTime={date.toISOString()}>
|
|
{date.toLocaleString()}
|
|
</time>
|
|
)
|
|
} |