mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
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');
|
||||
|
||||
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}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user