This commit is contained in:
Ryan Mwangi 2024-10-03 01:11:20 +03:00
parent 3438ae9396
commit f539e5d140
1 changed files with 18 additions and 0 deletions

View File

@ -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) { } catch (error) {
console.error(error); console.error(error);