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..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 { zonedTimeToUtc } from 'date-fns-tz'; +import { 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