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