From ba597a2556671b8b0dd106f200edf8664cb531c7 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 29 Oct 2024 15:32:17 +0300 Subject: [PATCH] check if the event is date-based or time-based --- server.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index 4331474..0ee5a3d 100644 --- a/server.js +++ b/server.js @@ -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 - calendar.createEvent({ - start: start, - end: end, - summary: summary, - }); + // 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 + }); + } }); });