Skip to content

Scheduling infrastructure for absolutely everyone.

fixed calendso busy query timezone issue (#1360)

Nathaniel7f5a2363f946
diff --git a/lib/integrations/calendar/services/BaseCalendarService.ts b/lib/integrations/calendar/services/BaseCalendarService.ts
index dbc3a7b5144..2583e5b0aab 100644
--- a/lib/integrations/calendar/services/BaseCalendarService.ts
+++ b/lib/integrations/calendar/services/BaseCalendarService.ts
@@ -1,5 +1,7 @@
import { Credential } from "@prisma/client";
import dayjs from "dayjs";
+import timezone from "dayjs/plugin/timezone";
+import utc from "dayjs/plugin/utc";
import ICAL from "ical.js";
import { createEvent } from "ics";
import {
@@ -24,6 +26,9 @@ import { CalendarEventType, EventBusyDate, NewCalendarEventType } from "../const
import { Calendar, CalendarEvent, IntegrationCalendar } from "../interfaces/Calendar";
import { convertDate, getAttendees, getDuration } from "../utils/CalendarUtils";
+dayjs.extend(utc);
+dayjs.extend(timezone);
+
const CALENDSO_ENCRYPTION_KEY = process.env.CALENDSO_ENCRYPTION_KEY || "";
export default abstract class BaseCalendarService implements Calendar {
@@ -291,11 +296,11 @@ export default abstract class BaseCalendarService implements Calendar {
vcalendar.getFirstSubcomponent("vtimezone")?.getFirstPropertyValue("tzid") || "";
const startDate = calendarTimezone
- ? dayjs(event.startDate.toJSDate()).tz(calendarTimezone)
+ ? dayjs.tz(event.startDate.toString(), calendarTimezone)
: new Date(event.startDate.toUnixTime() * 1000);
const endDate = calendarTimezone
- ? dayjs(event.endDate.toJSDate()).tz(calendarTimezone)
+ ? dayjs.tz(event.endDate.toString(), calendarTimezone)
: new Date(event.endDate.toUnixTime() * 1000);
return {