/** * Format a Date as YYYY-MM-DD in an IANA timezone. * * Uses "en-CA" because that locale natively produces ISO-style dates, * so we don't have to reassemble parts. */ export function formatLocalDate(d: Date, tz: string): string { return new Intl.DateTimeFormat("en-CA", { timeZone: tz, year: "numeric", month: "2-digit", day: "2-digit", }).format(d); } /** * Format a Date as HH:MM (24-hour) in an IANA timezone. */ export function formatLocalTime(d: Date, tz: string): string { const parts = new Intl.DateTimeFormat("en-GB", { timeZone: tz, hour: "2-digit", minute: "2-digit", hour12: false, }).formatToParts(d); const h = parts.find((p) => p.type === "hour")?.value ?? "00"; const m = parts.find((p) => p.type === "minute")?.value ?? "00"; return `${h}:${m}`; }