fix(core): timezone aware datetime display (#13055)

fixes #12803



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved time display for calendar events to correctly reflect
timezone differences. Times are now accurately formatted and displayed
based on the user's timezone.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Yifei Yin
2025-07-06 21:37:10 -04:00
committed by GitHub
parent e8857d51b1
commit 2df4a60c44

View File

@@ -24,8 +24,13 @@ import * as styles from './calendar-events.css';
const pad = (val?: number) => (val ?? 0).toString().padStart(2, '0');
function formatTime(start?: ICAL.Time, end?: ICAL.Time) {
const from = `${pad(start?.hour)}:${pad(start?.minute)}`;
const to = `${pad(end?.hour)}:${pad(end?.minute)}`;
if (!start || !end) return '';
// Use toJSDate which handles timezone conversion for us
const startDate = start.toJSDate();
const endDate = end.toJSDate();
const from = `${pad(startDate.getHours())}:${pad(startDate.getMinutes())}`;
const to = `${pad(endDate.getHours())}:${pad(endDate.getMinutes())}`;
return from === to ? from : `${from} - ${to}`;
}