From 0d662358cd2cc487322c6039c9682dd32a43774e Mon Sep 17 00:00:00 2001 From: lenhanphung Date: Wed, 17 Sep 2025 18:12:53 +0700 Subject: [PATCH] fix: add timezone fallback for event creation - Fix timezone lookup error in calendarEventToJCal - Add UTC fallback when timezone not found --- src/features/Events/eventUtils.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/features/Events/eventUtils.ts b/src/features/Events/eventUtils.ts index c92ec07..503b9b7 100644 --- a/src/features/Events/eventUtils.ts +++ b/src/features/Events/eventUtils.ts @@ -234,8 +234,17 @@ export function calendarEventToJCal( ]); }); + const timezoneData = TIMEZONES.zones[event.timezone]; + if (!timezoneData) { + const vtimezone = new ICAL.Timezone({ + component: TIMEZONES.zones["Etc/UTC"].ics, + tzid: "Etc/UTC", + }); + return ["vcalendar", [], [vevent, vtimezone.component.jCal]]; + } + const vtimezone = new ICAL.Timezone({ - component: TIMEZONES.zones[event.timezone].ics, + component: timezoneData.ics, tzid: event.timezone, }); return ["vcalendar", [], [vevent, vtimezone.component.jCal]];