icsParser PHP Class
I wrote this class after searching for a php class that would parse an ical file that included a multiline description.
Most will only parse the first line of the description field on ignore it. So after a few days for searching and trying ones, I decided to write on myself. The parser will return four parts of an ical cal entry (start date, end date, summary, description). It will then return all or part of the ical file as a JSON object.It has been tested on ical files that are generated by an Exchange server.
Any help in improving it is much appreciated.
Usage To instantiate the class you can do the following:
$icalFile = (ical file location);
$icsData = new icsParser($icalFile);
Public Methods There are four public methods:
-
setDateFormat: allows you to set how you want the start/end date to be formatted using php date formats
$icsData->setDateFormat('start', 'Y-m-d');
-
getAllEvents: Returns all entries in the ical file.
$icsData->getAllEvents();
-
getUpcomingEvents: Returns the next (X number) of events
$icsData->getUpcomingEvents(10); //returns next 10 events
-
getEventsByMonth: Returns all entries for a specific month and year;
$icsData->getEventsByMonth(11, 2012); //returns all events for Nov. 2012