From 8031333bce093877bf062026d8e349a4c32898a4 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 29 Oct 2024 02:31:58 +0300 Subject: [PATCH] save the calendar to a file --- server.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/server.js b/server.js index ba1c762..1318f3d 100644 --- a/server.js +++ b/server.js @@ -159,22 +159,8 @@ app.get('/calendar/:name', async (req, res) => { }); }); - //save merged calendar to file - let icalString = `BEGIN:VCALENDAR - VERSION:2.0 - CALSCALE:GREGORIAN - METHOD:PUBLISH - `; - mergedCal.forEach((event) => { - icalString += `BEGIN:VEVENT - DTSTART;VALUE=DATETIME:${event.start.toISOString().replace(/-|:|\.\d{3}/g, '')} - DTEND;VALUE=DATETIME:${event.end.toISOString().replace(/-|:|\.\d{3}/g, '')} - SUMMARY:${event.summary} - END:VEVENT - `; - }); - icalString += `END:VCALENDAR`; - fs.writeFileSync(icsFilePath, icalString); + // Save the calendar to a file + fs.writeFileSync(icsFilePath, calendar.toString()); console.log('Calendar data refreshed.'); }