fixed sync

This commit is contained in:
2026-03-05 09:35:04 +00:00
parent a36d55eae5
commit 4ff4f9572d
4 changed files with 457 additions and 330 deletions

37
lib/dates.ts Normal file
View File

@@ -0,0 +1,37 @@
const DASH = "—";
const DATE_TIME_FORMATTER = new Intl.DateTimeFormat("en-GB", {
timeZone: "UTC",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
});
const DATE_FORMATTER = new Intl.DateTimeFormat("en-GB", {
timeZone: "UTC",
year: "numeric",
month: "2-digit",
day: "2-digit",
});
function toValidDate(value?: string | Date | null): Date | null {
if (!value) return null;
const date = value instanceof Date ? value : new Date(value);
return Number.isNaN(date.getTime()) ? null : date;
}
export function formatDateTime(value?: string | Date | null): string {
const date = toValidDate(value);
if (!date) return DASH;
return `${DATE_TIME_FORMATTER.format(date)} UTC`;
}
export function formatDate(value?: string | Date | null): string {
const date = toValidDate(value);
if (!date) return DASH;
return DATE_FORMATTER.format(date);
}