fix: preserve original timezone when reopening event update modal

- Add formatDateTimeInTimezone() helper to format dates in event's original timezone
- Fix EventUpdateModal to display event times in original timezone instead of browser timezone
- Fix EventModal (duplicate event) with same timezone handling
- Update EventDisplay tests to use flexible date pattern
This commit is contained in:
lenhanphung
2025-10-07 17:50:23 +07:00
committed by Benoit TELLIER
parent 732c2cd051
commit 64393bf161
6 changed files with 48 additions and 34 deletions
+1 -5
View File
@@ -133,11 +133,7 @@ export function PeopleSearch({
if (selectedUsers.find((u) => u.email === option.email)) return null;
const { key, ...otherProps } = props as any;
return (
<ListItem
key={key}
{...otherProps}
disableGutters
>
<ListItem key={key} {...otherProps} disableGutters>
<ListItemAvatar>
<Avatar src={option.avatarUrl} alt={option.displayName} />
</ListItemAvatar>
+25
View File
@@ -561,3 +561,28 @@ export function formatLocalDateTime(date: Date): string {
date.getDate()
)}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
export function formatDateTimeInTimezone(
isoString: string,
timezone: string
): string {
// Parse the ISO string as UTC
const utcDate = new Date(isoString);
// Format the date in the target timezone
const formatter = new Intl.DateTimeFormat("en-CA", {
timeZone: timezone,
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
hour12: false,
});
const parts = formatter.formatToParts(utcDate);
const getValue = (type: string) =>
parts.find((p) => p.type === type)?.value || "";
return `${getValue("year")}-${getValue("month")}-${getValue("day")}T${getValue("hour")}:${getValue("minute")}`;
}