Auto-reply: include weekday in envelope timestamps (#12438)

This commit is contained in:
Mariano
2026-02-09 08:55:50 +01:00
committed by GitHub
parent e4651d6afa
commit 8968d9a339
3 changed files with 52 additions and 13 deletions

View File

@@ -7,13 +7,30 @@ type EnvelopeTimestampZone = string;
export function formatEnvelopeTimestamp(date: Date, zone: EnvelopeTimestampZone = "utc"): string {
const normalized = zone.trim().toLowerCase();
const weekday = (() => {
try {
if (normalized === "utc" || normalized === "gmt") {
return new Intl.DateTimeFormat("en-US", { timeZone: "UTC", weekday: "short" }).format(date);
}
if (normalized === "local" || normalized === "host") {
return new Intl.DateTimeFormat("en-US", { weekday: "short" }).format(date);
}
return new Intl.DateTimeFormat("en-US", { timeZone: zone, weekday: "short" }).format(date);
} catch {
return undefined;
}
})();
if (normalized === "utc" || normalized === "gmt") {
return formatUtcTimestamp(date);
const ts = formatUtcTimestamp(date);
return weekday ? `${weekday} ${ts}` : ts;
}
if (normalized === "local" || normalized === "host") {
return formatZonedTimestamp(date) ?? formatUtcTimestamp(date);
const ts = formatZonedTimestamp(date) ?? formatUtcTimestamp(date);
return weekday ? `${weekday} ${ts}` : ts;
}
return formatZonedTimestamp(date, { timeZone: zone }) ?? formatUtcTimestamp(date);
const ts = formatZonedTimestamp(date, { timeZone: zone }) ?? formatUtcTimestamp(date);
return weekday ? `${weekday} ${ts}` : ts;
}
export function formatLocalEnvelopeTimestamp(date: Date): string {