1
0
Fork 0

parse calendar data

This commit is contained in:
Ryan Mwangi 2024-10-03 01:10:27 +03:00
parent 9b297aa0fd
commit 3438ae9396
1 changed files with 16 additions and 0 deletions

View File

@ -116,6 +116,22 @@ async function updateMergedCalendar(){
const results = await Promise.all(promises);
// Filter out any failed requests
const validResults = results.filter((result) => result !== null);
// Parse calendar data
const mergedCal = [];
validResults.forEach((result) => {
const calendar = ical.parseICS(result.data);
Object.keys(calendar).forEach((key) => {
const event = calendar[key];
mergedCal.push({
start: event.start,
end: event.end,
summary: `${result.prefix} ${event.summary}`,
});
});
});
} catch (error) {
console.error(error);
}