From 9c0fd374b1e7302df1facb47f78a619d383af1f7 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 00:05:32 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/lib/format.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/format.ts b/src/lib/format.ts index 055eb44..943d822 100644 --- a/src/lib/format.ts +++ b/src/lib/format.ts @@ -5,6 +5,20 @@ export function formatCurrency(amount: number | string | null | undefined) { export function formatDate(value: string | Date | null | undefined) { if (!value) return "—"; + // Date-only strings ("YYYY-MM-DD") must be rendered in UTC, otherwise + // negative-offset timezones show the previous day. + if (typeof value === "string") { + const m = value.match(/^(\d{4})-(\d{2})-(\d{2})$/); + if (m) { + const d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3])); + return d.toLocaleDateString("en-US", { + year: "numeric", + month: "short", + day: "numeric", + timeZone: "UTC", + }); + } + } const d = typeof value === "string" ? new Date(value) : value; return d.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }); }