From 7c7fc72db9af9a3853b9afa8fc3a964bdf29c9ab Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 12 Dec 2025 09:53:35 +0100 Subject: [PATCH] format date as long date string by locale. eg. Friday 21 December 2025 --- .../(main)/match/components/pdf/InfoTable.tsx | 4 +++- src/utils/formatDate.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/[locale]/(main)/match/components/pdf/InfoTable.tsx b/src/app/[locale]/(main)/match/components/pdf/InfoTable.tsx index b8a6b6c..16f65d6 100644 --- a/src/app/[locale]/(main)/match/components/pdf/InfoTable.tsx +++ b/src/app/[locale]/(main)/match/components/pdf/InfoTable.tsx @@ -1,5 +1,7 @@ import { Text, View } from "@react-pdf/renderer"; +import { longDateLocaleString } from "@/utils/formatDate"; + import { styles } from "./styles"; interface IProps { @@ -20,7 +22,7 @@ const InfoTable = ({ date, lieu, ronde }: IProps) => ( {/* Data Row */} - {date ? new Date(date).toLocaleDateString("fr-FR") : " "} + {date ? longDateLocaleString({ date, locale: "fr-FR" }) : ""} {lieu || " "} {ronde || " "} diff --git a/src/utils/formatDate.ts b/src/utils/formatDate.ts index 4cef0b3..51ded22 100644 --- a/src/utils/formatDate.ts +++ b/src/utils/formatDate.ts @@ -8,3 +8,18 @@ const formatDate = (inputDate: any) => { }; export default formatDate; + +export const longDateLocaleString = ({ + date, + locale, +}: { + date: Date; + locale: string; +}) => { + return date.toLocaleDateString(locale, { + weekday: "long", + day: "numeric", + month: "long", + year: "numeric", + }); +};