- Fixed wrong date format when saving the google events

This commit is contained in:
Dejan
2024-10-04 01:28:56 +02:00
parent ba74025589
commit fc0ea611af

View File

@ -15,19 +15,12 @@ export async function fetchGoogleCalendarEvents(token, startDate) {
const start = item.start; const start = item.start;
let startDateTime; let startDateTime;
if (start !== undefined) { if (start !== undefined) {
const timezone = start.timeZone;
if (start.dateTime) { if (start.dateTime) {
const stringDate = start.dateTime; const stringDate = start.dateTime;
startDateTime = new Date(stringDate).toLocaleString("en-us", { startDateTime = new Date(stringDate);
...options,
timeZone: timezone,
});
} else { } else {
const stringDate = start.date; const stringDate = start.date;
startDateTime = new Date(stringDate).toLocaleString("en-us", { startDateTime = new Date(stringDate);
...options,
timeZone: timezone,
});
isAllDay = true; isAllDay = true;
} }
} }
@ -35,19 +28,12 @@ export async function fetchGoogleCalendarEvents(token, startDate) {
const end = item.end; const end = item.end;
let endDateTime; let endDateTime;
if (end !== undefined) { if (end !== undefined) {
const timezone = end.timeZone;
if (end.dateTime) { if (end.dateTime) {
const stringDate = end.dateTime; const stringDate = end.dateTime;
endDateTime = new Date(stringDate).toLocaleString("en-us", { endDateTime = new Date(stringDate);
...options,
timeZone: timezone,
});
} else { } else {
const stringDate = end.date; const stringDate = end.date;
endDateTime = new Date(stringDate).toLocaleString("en-us", { endDateTime = new Date(stringDate);
...options,
timeZone: timezone,
});
} }
} }
@ -63,13 +49,3 @@ export async function fetchGoogleCalendarEvents(token, startDate) {
return googleEvents; return googleEvents;
} }
const options = {
year: "numeric",
month: "long",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
timeZoneName: "short",
};