From 55af529c76fa3d9c505369ca3eeb8cb7d14984a2 Mon Sep 17 00:00:00 2001 From: Dicken Date: Fri, 5 Jun 2026 18:43:56 +0200 Subject: [PATCH] Fix Kalender Uhrzeit: UTC-Z korrekt nach Europe/Berlin konvertieren --- frontend/src/App.jsx | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 3ec1e97..41f6349 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1432,12 +1432,28 @@ function ChangelogModal({ user, toast, onClose, onRead }) { } function formatIcalDate(dt) { if (!dt) return ''; - const clean = dt.replace('Z',''); - const date = clean.slice(0,8); - if (date.length < 8) return dt; - const d = date.slice(6,8), m = date.slice(4,6), y = date.slice(0,4); - const tm = clean.match(/T(\d{2})(\d{2})/); - return tm ? `${d}.${m}.${y}, ${tm[1]}:${tm[2]} Uhr` : `${d}.${m}.${y}`; + try { + const hasTime = dt.includes('T'); + const isUTC = dt.endsWith('Z'); + const y = dt.slice(0,4), mo = dt.slice(4,6), d = dt.slice(6,8); + if (hasTime) { + const h = dt.slice(9,11), mi = dt.slice(11,13), s = dt.slice(13,15)||'00'; + const iso = `${y}-${mo}-${d}T${h}:${mi}:${s}${isUTC?'Z':''}`; + const date = new Date(iso); + if (isNaN(date)) return dt; + return date.toLocaleString('de-DE', { + timeZone:'Europe/Berlin', + day:'2-digit', month:'2-digit', year:'numeric', + hour:'2-digit', minute:'2-digit' + }) + ' Uhr'; + } else { + const date = new Date(`${y}-${mo}-${d}T12:00:00Z`); + if (isNaN(date)) return dt; + return date.toLocaleDateString('de-DE', { + timeZone:'Europe/Berlin', day:'2-digit', month:'2-digit', year:'numeric' + }); + } + } catch { return dt.slice(0,10); } } function SearchResultItem({ item, idx, activeIdx, onNavigate, onHover }) {