fix(03): WR-03 use cleaned string for all-day check in parseDateTime

This commit is contained in:
Lucas Berger
2026-06-09 10:39:54 -04:00
parent 5499f83782
commit d34edece96
+5 -2
View File
@@ -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')