diff --git a/src/routes/api/social/calendar/[slug]/+server.ts b/src/routes/api/social/calendar/[slug]/+server.ts index a6b8a0e..9e75af0 100644 --- a/src/routes/api/social/calendar/[slug]/+server.ts +++ b/src/routes/api/social/calendar/[slug]/+server.ts @@ -97,18 +97,23 @@ async function loadFonts() { return fontCache; } +// terminZeit ist mit Offset gespeichert (z. B. 10:00+02:00 = 08:00 UTC). +// Rendering muss in Europe/Berlin erzwungen werden — sonst rendert der +// SSR-Prozess (Server-TZ = UTC) 2h zu früh (10 Uhr → 8 Uhr auf dem Bild). +const TZ = "Europe/Berlin"; + function formatDate(iso: string | undefined): { date: string; time: string | null } { if (!iso) return { date: "", time: null }; const d = new Date(iso); - const date = d.toLocaleDateString("de-DE", { day: "2-digit", month: "long", year: "numeric" }); + const date = d.toLocaleDateString("de-DE", { day: "2-digit", month: "long", year: "numeric", timeZone: TZ }); const hasTime = !/T00:00:00/.test(iso); - const time = hasTime ? d.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit" }) : null; + const time = hasTime ? d.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit", timeZone: TZ }) : null; return { date, time }; } function weekday(iso: string | undefined): string { if (!iso) return ""; - return new Date(iso).toLocaleDateString("de-DE", { weekday: "long" }); + return new Date(iso).toLocaleDateString("de-DE", { weekday: "long", timeZone: TZ }); } /** @@ -139,7 +144,7 @@ async function loadEventImage( const cache = new Map(); const CACHE_TTL = 10 * 60_000; // 10min -const CACHE_VERSION = "v26"; +const CACHE_VERSION = "v27"; function parseFormat(v: string | null): Format { if (v === "square") return "square"; diff --git a/src/routes/api/social/post/[slug]/+server.ts b/src/routes/api/social/post/[slug]/+server.ts index b5bbdfe..3fc7064 100644 --- a/src/routes/api/social/post/[slug]/+server.ts +++ b/src/routes/api/social/post/[slug]/+server.ts @@ -90,6 +90,7 @@ function formatDateLong(iso: string | undefined | null): string { day: "2-digit", month: "long", year: "numeric", + timeZone: "Europe/Berlin", }); } catch { return "";