Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: How to parse an ics / ical file

What is the best way to parse an ical / ics file? I have it all in a string, but I cant find a package or library that is compatible with RN. All the general JS or Node ones throw errors about the FS package missing. I am reading it in from a URL and have it all in memory so I don't even need file system access.

like image 897
AdamG Avatar asked Oct 08 '17 18:10

AdamG


1 Answers

Anyone looking for the answer to this question in 2019+, I've written an npm module to solve this problem! You can find it here! (https://github.com/Christop406/ical-parser).

Or, if you're lazy, just run npm i cal-parser (NOT ical-parser).

You can use it like this:

const ical = require('cal-parser');

var parsedCal = ical.parseString(MY_ICAL_STRING);

console.log(parsedCal.calendarData); // for calendar metadata
console.log(parsedCal.events);       // for calendar events

Happy parsing!

like image 168
Chris Gilardi Avatar answered Sep 24 '22 19:09

Chris Gilardi