From f3a6c8940aa705d336cca4e9695e5acec6d44a89 Mon Sep 17 00:00:00 2001 From: Luca <102960244+Luca-Timo@users.noreply.github.com> Date: Wed, 3 Jun 2026 11:23:58 +0200 Subject: [PATCH] fix(date-input): render pg full-ISO dates in the configured format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LocalizedDateInput.toDisplay only matched a bare yyyy-MM-dd, but Postgres serializes DATE columns as a full ISO datetime, so the field printed the raw "2026-…T…Z" string (SQLite returned a bare date, hiding it). Match the leading yyyy-MM-dd of any ISO value and slice the hidden native picker's value to 10 chars. Fixes ISO-form dates on customer/event/passive-create. --- .../src/components/common/LocalizedDateInput.tsx | 15 +++++++++++---- frontend/src/i18n/locales/de.json | 1 + frontend/src/i18n/locales/en.json | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/common/LocalizedDateInput.tsx b/frontend/src/components/common/LocalizedDateInput.tsx index 03fe0003..fdc3553b 100644 --- a/frontend/src/components/common/LocalizedDateInput.tsx +++ b/frontend/src/components/common/LocalizedDateInput.tsx @@ -53,11 +53,16 @@ export const LocalizedDateInput: React.FC = ({ })(); const placeholder = normalisedFormat.toLowerCase(); - // ISO → display + // ISO → display. NOTE: no `$` anchor — Postgres serialises DATE columns + // as a full ISO datetime ("2026-04-06T00:00:00.000Z"), so we match the + // leading yyyy-MM-dd and ignore any trailing time. (SQLite returns the + // bare date string, which also matches.) Coerced to String in case a + // Date object slips through. Without this the field rendered the raw + // ISO timestamp on pg — see feedback_pg_date_columns_serialize. const toDisplay = (iso: string): string => { if (!iso) return ''; - const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso); - if (!m) return iso; + const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso)); + if (!m) return String(iso); const [, y, mo, d] = m; switch (normalisedFormat) { case 'MM/DD/YYYY': return `${mo}/${d}/${y}`; @@ -148,7 +153,9 @@ export const LocalizedDateInput: React.FC = ({