From d34edece9695dbfc8f3e12affffde01083b65c8b Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Tue, 9 Jun 2026 10:39:54 -0400 Subject: [PATCH] fix(03): WR-03 use cleaned string for all-day check in parseDateTime --- apps/pwa/src/components/EventForm.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/pwa/src/components/EventForm.tsx b/apps/pwa/src/components/EventForm.tsx index a6e272f..d93f9a0 100644 --- a/apps/pwa/src/components/EventForm.tsx +++ b/apps/pwa/src/components/EventForm.tsx @@ -108,9 +108,12 @@ function parseDateTime(iso: string): { date: string; time: string } { try { // Strip IANA bracket suffix e.g. '[America/Toronto]' const clean = iso.replace(/\[[^\]]*\]$/, '') - if (/^\d{4}-\d{2}-\d{2}$/.test(iso)) { + // WR-03: test and return `clean`, not the raw `iso`. Testing `iso` would let a + // date-only value carrying a bracket suffix skip the all-day branch and fall through + // to new Date(clean); using `clean` matches the "strip IANA suffix" intent above. + if (/^\d{4}-\d{2}-\d{2}$/.test(clean)) { // All-day date string — use as-is (no time component) - return { date: iso, time: '09:00' } + return { date: clean, time: '09:00' } } const d = new Date(clean) if (isNaN(d.getTime())) throw new Error('Invalid date')