fix: Outlook event timezone offset on create/update responses
Outlook Graph API returns datetimes in the user's timezone without Z suffix by default. The sync path already requested UTC and appended Z, but create/update responses did not. This caused the optimistic UI update to show events 1 hour off until the next sync corrected it. Fix: add Prefer: outlook.timezone="UTC" header to create/update calls and normalize response datetimes with Z suffix. v1.71.3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
92593cf616
commit
131f92bd72
@ -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": {
|
||||
|
||||
@ -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<string, string> = {
|
||||
'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
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user