(value: string | Date | undefined)
| 54 | * (UTC midnight) produces in negative-offset timezones. |
| 55 | */ |
| 56 | export function parseDateValue(value: string | Date | undefined): Date | null { |
| 57 | if (!value) return null |
| 58 | if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value |
| 59 | if (/^\d{4}-\d{2}-\d{2}/.test(value)) { |
| 60 | const [year, month, day] = value.slice(0, 10).split('-').map(Number) |
| 61 | return new Date(year, month - 1, day) |
| 62 | } |
| 63 | const parsed = new Date(value) |
| 64 | return Number.isNaN(parsed.getTime()) ? null : parsed |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Human-readable label for a date value (e.g. `May 8, 2026`). Returns an empty |
no test coverage detected