From 1258b24864f606da6abfaf8d2efb59ab53290e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 10 May 2026 14:25:28 +0200 Subject: [PATCH] fix(admin): render token-name timestamps in Berlin time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-issued token-name viewer rebuilt the dd.MM.yyyy HH:mm suffix from `Date.getUTC*` accessors, producing 19:46 instead of the 21:46 a Berlin-time admin would expect for a token issued at 19:46 UTC. Route the parsed Date through `Intl.DateTimeFormat("de-DE", { timeZone: "Europe/Berlin", … })` so the embedded timestamp matches every other display surface in the app. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../admin/api-token-overview-section.tsx | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/admin/api-token-overview-section.tsx b/src/components/admin/api-token-overview-section.tsx index 38af855e7..9efec6d92 100644 --- a/src/components/admin/api-token-overview-section.tsx +++ b/src/components/admin/api-token-overview-section.tsx @@ -66,18 +66,30 @@ function TruncatedCell({ const TOKEN_NAME_ISO_RE = /^(.+?)\s+(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z)(.*)$/; +// Locale-fixed dd.MM.yyyy HH:mm in the Europe/Berlin display zone — the +// rest of the app shows timestamps in Berlin time (`format-locale.ts`), +// so a token issued at 19:46 UTC must read as 21:46 in summer / 20:46 +// in winter, not the raw UTC clock. +const TOKEN_NAME_DATE_FORMATTER = new Intl.DateTimeFormat("de-DE", { + timeZone: "Europe/Berlin", + day: "2-digit", + month: "2-digit", + year: "numeric", + hour: "2-digit", + minute: "2-digit", + hour12: false, +}); + function formatTokenName(name: string): string { const match = TOKEN_NAME_ISO_RE.exec(name); if (!match) return name; const [, prefix, iso, rest] = match; const d = new Date(iso); if (Number.isNaN(d.getTime())) return name; - const dd = String(d.getUTCDate()).padStart(2, "0"); - const mm = String(d.getUTCMonth() + 1).padStart(2, "0"); - const yyyy = d.getUTCFullYear(); - const hh = String(d.getUTCHours()).padStart(2, "0"); - const mi = String(d.getUTCMinutes()).padStart(2, "0"); - const formatted = `${prefix} · ${dd}.${mm}.${yyyy} ${hh}:${mi}`; + // Intl emits "05.05.2026, 21:46" — strip the comma so the suffix + // reads as a single date+time chunk. + const stamp = TOKEN_NAME_DATE_FORMATTER.format(d).replace(",", ""); + const formatted = `${prefix} · ${stamp}`; return rest && rest.trim() ? `${formatted} ${rest.trim()}` : formatted; }