// Conversions between the compact "YYYYMMDD" date keys used throughout the // export data (e.g. `DisplaySummary.uploadDate`) and the "YYYY-MM-DD" strings // that `` expects. Shared by the charts FilterBar and the // search date filter. // "20260513" -> "2026-05-13" for . Returns "" for anything // that isn't a well-formed 8-digit key. export function ymdToInput(ymd?: string): string { if (!ymd || !/^\d{8}$/.test(ymd)) return ""; return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`; } // "2026-05-13" -> "20260513". Returns undefined when the input is empty or // malformed (e.g. a cleared date input). export function inputToYmd(v: string): string | undefined { const m = v.match(/^(\d{4})-(\d{2})-(\d{2})$/); return m ? `${m[1]}${m[2]}${m[3]}` : undefined; }