ice_cube icon indicating copy to clipboard operation
ice_cube copied to clipboard

Added support for parsing VEVENT from iCal format

Open iainbeeston opened this issue 6 years ago • 1 comments

BACKGROUND

I have an ical file I'd like to parse with ice cube. It has no recurring events, just a series of one off events. Those events are stored in the file as VEVENTs, where each event is a block of lines all describing a single event, starting with BEGIN:VEVENT and ending with END:VEVENT (more detail here).

CURRENT BEHAVIOUR

Icecube can't parse these events. It sees the DTSTART and DTEND inside the VEVENT, but applies them to the schedule.

EXPECTED BEHAVIOUR

I would have expected it to add each VEVENT as it's own recurrence time in the new schedule.

SOLUTION

I've refactored the ical parser such that it acts as a state machine. By default it works as it did before. However, if it sees a BEGIN:VEVENT line it goes into an event parsing mode, where it parses subsequent lines as events. Once it sees an END:VEVENT line, it goes back to the regular mode. When parsing events it adds a new recurrence time every time it sees a DTSTART.

NOTES

  • To keep the code simple, if there are multiple DTSTART lines within an event, it will add a new recurrence time for each of them. A VEVENT with more than one DTSTART is invalid, so this shouldn't happen in practice.
  • VEVENTs can have an end date (ie. DTEND) as well as a start date (DTSTART). I couldn't see a way of adding a duration to a recurrence time, so I've ignored the end dates for now.

iainbeeston avatar Jan 12 '19 16:01 iainbeeston

The build is failing because travis is trying to use bundler 2.0 with ruby < 2.3. #459 should fix that

iainbeeston avatar Jan 12 '19 16:01 iainbeeston