From 3ff99f787781f2eee4c86f8486641a1ec024a45a Mon Sep 17 00:00:00 2001 From: sec0ndhand <13591749+sec0ndhand@users.noreply.github.com> Date: Fri, 10 Dec 2021 12:00:03 -0700 Subject: [PATCH] Fix timezones being returned from office 365 (#1269) Per the [api documentation](https://docs.microsoft.com/en-us/graph/api/calendar-list-calendarview?view=graph-rest-1.0&tabs=javascript#query-parameters) the `Prefer: outlook.timezone` is ignored if a timezone value is passed in the request. This forces the dates to be passed in UTC. Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../Office365Calendar/Office365CalendarApiAdapter.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/integrations/Office365Calendar/Office365CalendarApiAdapter.ts b/lib/integrations/Office365Calendar/Office365CalendarApiAdapter.ts index 6369e64404..21ad4ddc5d 100644 --- a/lib/integrations/Office365Calendar/Office365CalendarApiAdapter.ts +++ b/lib/integrations/Office365Calendar/Office365CalendarApiAdapter.ts @@ -115,9 +115,12 @@ export const Office365CalendarApiAdapter = (credential: Credential): CalendarApi return { getAvailability: (dateFrom, dateTo, selectedCalendars) => { - const filter = `?startdatetime=${encodeURIComponent(dateFrom)}&enddatetime=${encodeURIComponent( - dateTo - )}`; + const dateFromParsed = new Date(dateFrom); + const dateToParsed = new Date(dateTo); + + const filter = `?startdatetime=${encodeURIComponent( + dateFromParsed.toISOString() + )}&enddatetime=${encodeURIComponent(dateToParsed.toISOString())}`; return auth .getToken() .then((accessToken) => { @@ -138,9 +141,6 @@ export const Office365CalendarApiAdapter = (credential: Credential): CalendarApi const requests = ids.map((calendarId, id) => ({ id, method: "GET", - headers: { - Prefer: 'outlook.timezone="Etc/GMT"', - }, url: `/me/calendars/${calendarId}/calendarView${filter}`, }));