1
0
Fork 0

parse calendar data in calendar/:name endpoint with ICAL

This commit is contained in:
Ryan Mwangi 2024-11-04 15:23:21 +03:00
parent c78b0501ea
commit c264c6b842
1 changed files with 11 additions and 0 deletions

View File

@ -175,6 +175,17 @@ app.get('/calendar/:name', async (req, res) => {
// Parse calendar data // Parse calendar data
validResults.forEach((result) => { validResults.forEach((result) => {
const parsed = ICAL.parse(result.data);
const component = new ICAL.Component(parsed);
const events = component.getAllSubcomponents('vevent');
events.forEach((event) => {
const vevent = new ICAL.Event(event);
const start = vevent.startDate.toJSDate();
const end = vevent.endDate.toJSDate();
const summary = result.override ? result.prefix : `${result.prefix} ${vevent.summary}`;
});
const parsedCalendar = ical.parseICS(result.data); const parsedCalendar = ical.parseICS(result.data);
Object.keys(parsedCalendar).forEach((key) => { Object.keys(parsedCalendar).forEach((key) => {
const event = parsedCalendar[key]; const event = parsedCalendar[key];