diff --git a/package.json b/package.json index 58c071d..f55d526 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.71.2", + "version": "1.71.3", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "main": "index.js", "scripts": { diff --git a/src/lib/outlook-calendar.ts b/src/lib/outlook-calendar.ts index ffe703a..cd802d2 100644 --- a/src/lib/outlook-calendar.ts +++ b/src/lib/outlook-calendar.ts @@ -272,6 +272,17 @@ const ensureTimeZone = (dateTimeObj: any) => { /** * Create Outlook Event */ +// Normalize Outlook response dateTime: ensure UTC dates have Z suffix +const normalizeOutlookDateTime = (dtObj: any) => { + if (!dtObj?.dateTime) return dtObj; + let dt = dtObj.dateTime; + // Outlook returns UTC datetimes without Z suffix — append it + if (dt && typeof dt === 'string' && dtObj.timeZone === 'UTC' && !dt.endsWith('Z')) { + dt = dt + 'Z'; + } + return { dateTime: dt, timeZone: dtObj.timeZone }; +}; + export const createEvent = async ( accessToken: string, calendarId: string, @@ -281,7 +292,8 @@ export const createEvent = async ( method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'Prefer': 'outlook.timezone="UTC"' }, body: JSON.stringify({ subject: event.summary, @@ -325,8 +337,8 @@ export const createEvent = async ( id: created.id, summary: created.subject, description: created.bodyPreview, - start: created.start, - end: created.end, + start: normalizeOutlookDateTime(created.start), + end: normalizeOutlookDateTime(created.end), location: created.location?.displayName, allDay: created.isAllDay }; @@ -372,9 +384,10 @@ export const updateEvent = async ( } : {}), }); - const patchHeaders = { + const patchHeaders: Record = { 'Authorization': `Bearer ${accessToken}`, - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'Prefer': 'outlook.timezone="UTC"' }; const encodedEventId = encodeURIComponent(eventId); @@ -402,8 +415,8 @@ export const updateEvent = async ( id: updated.id, summary: updated.subject, description: updated.bodyPreview, - start: updated.start, - end: updated.end, + start: normalizeOutlookDateTime(updated.start), + end: normalizeOutlookDateTime(updated.end), location: updated.location?.displayName, allDay: updated.isAllDay };