Fix timezone-aware calendar event times

Render timezone-aware calendar timestamps in the browser local timezone while preserving naive wall-clock timestamps.
This commit is contained in:
Chris Rowland
2026-06-01 12:15:58 +10:00
committed by GitHub
parent 4a04068818
commit 6c68631c26

View File

@@ -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, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }