blob: 7097ba3aee679205c3b05b6fe61bdf35c03abd4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Shared Temporal display helpers. Storage and logic stay in ISO instants;
// these format one for the viewer in their own timezone.
/** Format an ISO instant in the viewer's timezone. */
export function formatInstant(
iso: string,
options: Intl.DateTimeFormatOptions,
): string {
return Temporal.Instant.from(iso)
.toZonedDateTimeISO(Temporal.Now.timeZoneId())
.toLocaleString('fr-FR', options);
}
/** Short day-month stamp ("8 sept."). */
export function formatDayMonth(iso: string): string {
return formatInstant(iso, { day: 'numeric', month: 'short' });
}
/** Day-month-year stamp ("8 sept. 2026"). */
export function formatDayMonthYear(iso: string): string {
return formatInstant(iso, {
day: 'numeric',
month: 'short',
year: 'numeric',
});
}
|