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);