16 lines
494 B
TypeScript
16 lines
494 B
TypeScript
// Fixed locale and UTC keep server-rendered dates deterministic
|
|
// (no hydration mismatches, no test flakiness across machines).
|
|
const dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
dateStyle: "long",
|
|
timeZone: "UTC",
|
|
});
|
|
|
|
export function formatDate(date: Date | null | undefined): string {
|
|
if (!date) return "—";
|
|
return dateFormatter.format(date);
|
|
}
|
|
|
|
export function isoDate(date: Date | null | undefined): string | undefined {
|
|
return date ? date.toISOString() : undefined;
|
|
}
|