check if the event is date-based or time-based

This commit is contained in:
Ryan Mwangi 2024-10-29 15:32:17 +03:00
parent 67bdba2ee6
commit ba597a2556
1 changed files with 17 additions and 6 deletions

View File

@ -75,12 +75,23 @@ app.post('/merge', async (req, res) => {
const end = new Date(event.end);
const summary = result.override ? result.prefix : `${result.prefix} ${event.summary}`;
// Add event to the calendar
// Check if the event is date-based or time-based
if (event.start.includes('T')) {
// Time-based event
calendar.createEvent({
start: start,
end: end,
summary: summary,
});
} else {
// Date-based event
calendar.createEvent({
start: start,
end: end,
summary: summary,
allDay: true, // Mark as an all-day event
});
}
});
});