From d19fbf990bc22ba5089beacdec49a874a4a83255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sat, 24 Jan 2026 00:40:38 +0400 Subject: [PATCH] feat: ajout de la timezone pour les exports --- components/versions/export-pdf-button.js | 4 ++-- components/versions/print-button.js | 4 ++-- lib/format.js | 11 +++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/versions/export-pdf-button.js b/components/versions/export-pdf-button.js index 9eaef20..06ae409 100644 --- a/components/versions/export-pdf-button.js +++ b/components/versions/export-pdf-button.js @@ -159,7 +159,7 @@ export default function ExportPdfButton({versionData, isOutdated = false, size = Auteur : @${authorName}

- Date de création : ${formatDate(versionData.date_created, 'PPpp')} + Date de création : ${formatDate(versionData.date_created, 'PPpp', {withTimezone: true})}

Statut du vote : @@ -178,7 +178,7 @@ export default function ExportPdfButton({versionData, isOutdated = false, size =

- Exporté depuis Konstitisyon.nu le ${formatDate(new Date(), 'PPpp')} + Exporté depuis Konstitisyon.nu le ${formatDate(new Date(), 'PPpp', {withTimezone: true})}
` diff --git a/components/versions/print-button.js b/components/versions/print-button.js index 3dd6c80..0b57342 100644 --- a/components/versions/print-button.js +++ b/components/versions/print-button.js @@ -303,7 +303,7 @@ export default function PrintButton({versionData, isOutdated = false, size = 'me Auteur : @${authorName}
- Date de création : ${formatDate(versionData.date_created, 'PPpp')} + Date de création : ${formatDate(versionData.date_created, 'PPpp', {withTimezone: true})}
Statut du vote : @@ -319,7 +319,7 @@ export default function PrintButton({versionData, isOutdated = false, size = 'me
diff --git a/lib/format.js b/lib/format.js index 885e3ab..3563d53 100644 --- a/lib/format.js +++ b/lib/format.js @@ -19,10 +19,17 @@ export function formatKonstitisyon(titres, articles) { return konstitisyon } -export function formatDate(date, formatStr = 'PP') { - return format(date, formatStr, { +export function formatDate(date, formatStr = 'PP', {withTimezone = false} = {}) { + const formatted = format(date, formatStr, { locale: fr }) + + if (withTimezone) { + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone + return `${formatted} (${timezone})` + } + + return formatted } export function hasRestrictedChar(text) {