From f539e5d14032e3846c30408be6b48b4cd2d48aa2 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 3 Oct 2024 01:11:20 +0300 Subject: [PATCH] commit --- server.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server.js b/server.js index 6f59640..9aed2a0 100644 --- a/server.js +++ b/server.js @@ -131,6 +131,24 @@ async function updateMergedCalendar(){ }); }); + // Save merged calendar to file + const filename = `merged-${Date.now()}.ics`; + let icalString = `BEGIN:VCALENDAR +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:PUBLISH +BEGIN:VEVENT +`; + mergedCal.forEach((event) => { + icalString += `DTSTART:${event.start} +DTEND:${event.end} +SUMMARY:${event.summary} +END:VEVENT +`; + }); + icalString += `END:VCALENDAR`; + fs.writeFileSync(filename, icalString); + } catch (error) { console.error(error);