forked from ryanmwangi/CalMerger
save the calendar to a file
This commit is contained in:
parent
8927cc1cd3
commit
8031333bce
18
server.js
18
server.js
|
@ -159,22 +159,8 @@ app.get('/calendar/:name', async (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//save merged calendar to file
|
// Save the calendar to a file
|
||||||
let icalString = `BEGIN:VCALENDAR
|
fs.writeFileSync(icsFilePath, calendar.toString());
|
||||||
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);
|
|
||||||
|
|
||||||
console.log('Calendar data refreshed.');
|
console.log('Calendar data refreshed.');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue