From 6c68631c260a2a06be3b8a5230204c4c3640fe3b Mon Sep 17 00:00:00 2001 From: Chris Rowland Date: Mon, 1 Jun 2026 12:15:58 +1000 Subject: [PATCH] Fix timezone-aware calendar event times Render timezone-aware calendar timestamps in the browser local timezone while preserving naive wall-clock timestamps. --- static/js/calendar.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/static/js/calendar.js b/static/js/calendar.js index 0abf019..be1ca17 100644 --- a/static/js/calendar.js +++ b/static/js/calendar.js @@ -3082,8 +3082,16 @@ function _nowClock() { return new Date().toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' }); } function _fmtTime(s) { - // Show the time as written in the ICS file (ignore UTC offset). if (!s || s.length < 16) return ''; + // Tz-aware timestamps from CalDAV/import are stored as UTC instants and + // serialized with Z/offset. Display them in the browser's local timezone; + // legacy naive timestamps keep their written wall-clock time. + if (/[Zz]$|[+\-]\d{2}:?\d{2}$/.test(s)) { + const d = new Date(s); + if (!isNaN(d)) { + return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`; + } + } return s.slice(11, 16); } function _e(s) { return uiModule.esc ? uiModule.esc(s || '') : (s || '').replace(//g, '>').replace(/"/g, '"'); }