From a752485d5e2a0f3a7b72e8d822d493c834966d6f Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 4 Nov 2024 15:24:33 +0300 Subject: [PATCH] check if calendar is date based or event based in calendar/:name endpoint --- server.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server.js b/server.js index 7db8827..6d0e1e2 100644 --- a/server.js +++ b/server.js @@ -184,6 +184,21 @@ app.get('/calendar/:name', async (req, res) => { const start = vevent.startDate.toJSDate(); const end = vevent.endDate.toJSDate(); const summary = result.override ? result.prefix : `${result.prefix} ${vevent.summary}`; + + if (vevent.startDate.isDate) { + calendar.createEvent({ + start: start.toISOString().split('T')[0], + end: end.toISOString().split('T')[0], + summary: summary, + allDay: true, + }); + } else { + calendar.createEvent({ + start: start, + end: end, + summary: summary, + }); + } }); const parsedCalendar = ical.parseICS(result.data);