Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-19 00:05:32 +00:00
co-authored by renee-png
parent 0b0dd6cf70
commit 9c0fd374b1
+14
View File
@@ -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" });
}