Rejects the wrong shape and impossible dates alike (`2026-02-31` round-trips as March).
(day: string)
| 68 | |
| 69 | /** Rejects the wrong shape and impossible dates alike (`2026-02-31` round-trips as March). */ |
| 70 | function isValidDay(day: string): boolean { |
| 71 | if (!DAY_RE.test(day)) return false; |
| 72 | const t = Date.parse(`${day}T00:00:00Z`); |
| 73 | return Number.isFinite(t) && utcDay(t) === day; |
| 74 | } |
| 75 | |
| 76 | const dayMs = (day: string): number => Date.parse(`${day}T00:00:00Z`); |
| 77 | const addDays = (day: string, delta: number): string => utcDay(dayMs(day) + delta * DAY_MS); |