From a67ab815419677a086f69bfd8d0b3f0e8c3f4072 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 9 Jun 2022 23:55:49 +0200 Subject: [PATCH] Rename HumanDate to FestaMoment --- components/editable/EditableDateTimeLocal.tsx | 4 ++-- .../{HumanDate.tsx => extensions/FestaMoment.tsx} | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) rename components/{HumanDate.tsx => extensions/FestaMoment.tsx} (56%) diff --git a/components/editable/EditableDateTimeLocal.tsx b/components/editable/EditableDateTimeLocal.tsx index 40015f2..50412ec 100644 --- a/components/editable/EditableDateTimeLocal.tsx +++ b/components/editable/EditableDateTimeLocal.tsx @@ -1,5 +1,5 @@ import { HTMLProps } from "react"; -import { HumanDate } from "../HumanDate"; +import { FestaMoment } from "../extensions/FestaMoment"; import { Editable } from "./Editable"; export function EditableDateTimeLocal(props: HTMLProps & { value: Date }) { @@ -9,7 +9,7 @@ export function EditableDateTimeLocal(props: HTMLProps & { val } preview={ - + } /> ) diff --git a/components/HumanDate.tsx b/components/extensions/FestaMoment.tsx similarity index 56% rename from components/HumanDate.tsx rename to components/extensions/FestaMoment.tsx index 19f57bc..f81ceba 100644 --- a/components/HumanDate.tsx +++ b/components/extensions/FestaMoment.tsx @@ -4,11 +4,13 @@ type HumanDateProps = { date: Date } +/** + * Component that formats a {@link Date} to a machine-readable and human-readable HTML `time[datetime]` element. + */ +export function FestaMoment({ date }: HumanDateProps) { + const { t } = useTranslation() -export function HumanDate({date}: HumanDateProps) { - const {t} = useTranslation() - - if(Number.isNaN(date.getTime())) { + if (Number.isNaN(date.getTime())) { return ( {t("dateNaN")}