format date as long date string by locale. eg. Friday 21 December 2025

This commit is contained in:
2025-12-12 09:53:35 +01:00
parent 366dc6cd08
commit 7c7fc72db9
2 changed files with 18 additions and 1 deletions
@@ -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 */}
<View style={styles.infoRow}>
<Text style={styles.infoCell}>
{date ? new Date(date).toLocaleDateString("fr-FR") : " "}
{date ? longDateLocaleString({ date, locale: "fr-FR" }) : ""}
</Text>
<Text style={styles.infoCell}>{lieu || " "}</Text>
<Text style={[styles.infoCell, styles.lastCell]}>{ronde || " "}</Text>
+15
View File
@@ -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",
});
};