From 0de796928b06e24e16d8f1c9a8168692e705e240 Mon Sep 17 00:00:00 2001 From: anthogez Date: Tue, 21 Jan 2025 17:39:48 +0100 Subject: [PATCH 1/2] [Arvion] fix: upgrade package to new version --- graph-tutorial/package.json | 4 ++-- graph-tutorial/src/GraphService.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/graph-tutorial/package.json b/graph-tutorial/package.json index 4c2c779..fc641ab 100644 --- a/graph-tutorial/package.json +++ b/graph-tutorial/package.json @@ -8,8 +8,8 @@ "@microsoft/mgt-element": "^3.1.3", "@microsoft/microsoft-graph-client": "^3.0.7", "bootstrap": "^5.3.3", - "date-fns": "^2.29.2", - "date-fns-tz": "^2.0.1", + "date-fns": "4.1.0", + "date-fns-tz": "3.2.0", "react": "^18.3.1", "react-bootstrap": "^2.10.4", "react-dom": "^18.3.1", diff --git a/graph-tutorial/src/GraphService.ts b/graph-tutorial/src/GraphService.ts index ccf0a73..d81067f 100644 --- a/graph-tutorial/src/GraphService.ts +++ b/graph-tutorial/src/GraphService.ts @@ -5,7 +5,7 @@ import { Client, GraphRequestOptions, PageCollection, PageIterator } from '@microsoft/microsoft-graph-client'; import { AuthCodeMSALBrowserAuthenticationProvider } from '@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser'; import { endOfWeek, startOfWeek } from 'date-fns'; -import { zonedTimeToUtc } from 'date-fns-tz'; +import { toZonedTime, fromZonedTime } from 'date-fns-tz'; import { User, Event } from '@microsoft/microsoft-graph-types'; let graphClient: Client | undefined = undefined; @@ -41,8 +41,8 @@ export async function getUserWeekCalendar(authProvider: AuthCodeMSALBrowserAuthe // Generate startDateTime and endDateTime query params // to display a 7-day window const now = new Date(); - const startDateTime = zonedTimeToUtc(startOfWeek(now), timeZone).toISOString(); - const endDateTime = zonedTimeToUtc(endOfWeek(now), timeZone).toISOString(); + const startDateTime = fromZonedTime(startOfWeek(now), timeZone).toISOString(); + const endDateTime = fromZonedTime(endOfWeek(now), timeZone).toISOString(); // GET /me/calendarview?startDateTime=''&endDateTime='' // &$select=subject,organizer,start,end From 2200261d26629bebd1e7f2c3e083646a8cc8861d Mon Sep 17 00:00:00 2001 From: Antonio Firmiano Gomes Date: Tue, 21 Jan 2025 19:07:26 +0100 Subject: [PATCH 2/2] fix: remove unused import toZonedTime --- graph-tutorial/src/GraphService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph-tutorial/src/GraphService.ts b/graph-tutorial/src/GraphService.ts index d81067f..3fa2f7d 100644 --- a/graph-tutorial/src/GraphService.ts +++ b/graph-tutorial/src/GraphService.ts @@ -5,7 +5,7 @@ import { Client, GraphRequestOptions, PageCollection, PageIterator } from '@microsoft/microsoft-graph-client'; import { AuthCodeMSALBrowserAuthenticationProvider } from '@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser'; import { endOfWeek, startOfWeek } from 'date-fns'; -import { toZonedTime, fromZonedTime } from 'date-fns-tz'; +import { fromZonedTime } from 'date-fns-tz'; import { User, Event } from '@microsoft/microsoft-graph-types'; let graphClient: Client | undefined = undefined;