/** * Normalises input to YYYY-MM-DD string * - Strings are passed through as is * - Date objects are converted to UK time */ export const ensureDateString = (input: Date | string): string => { if (typeof input === 'string') return input.trim(); const d = new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: 'Europe/London' }).formatToParts(input); const part = (type: string) => d.find(p => p.type === type)?.value; return `${part('year')}-${part('month')}-${part('day')}` }