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:
@@ -24,8 +24,13 @@ import * as styles from './calendar-events.css';
|
|||||||
const pad = (val?: number) => (val ?? 0).toString().padStart(2, '0');
|
const pad = (val?: number) => (val ?? 0).toString().padStart(2, '0');
|
||||||
|
|
||||||
function formatTime(start?: ICAL.Time, end?: ICAL.Time) {
|
function formatTime(start?: ICAL.Time, end?: ICAL.Time) {
|
||||||
const from = `${pad(start?.hour)}:${pad(start?.minute)}`;
|
if (!start || !end) return '';
|
||||||
const to = `${pad(end?.hour)}:${pad(end?.minute)}`;
|
// 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}`;
|
return from === to ? from : `${from} - ${to}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user