mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-22 20:16:57 +00:00
format date as long date string by locale. eg. Friday 21 December 2025
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user