Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python solution to parse Google calendar's recurrencies

I'm trying to parse GCal's recurrence field. Usually, it looks like this:

DTSTART;TZID=Europe/Kiev:20101111T140000
DTEND;TZID=Europe/Kiev:20101111T150000
RRULE:FREQ=DAILY;UNTIL=20101112T120000Z
BEGIN:VTIMEZONE
TZID:Europe/Kiev
X-LIC-LOCATION:Europe/Kiev
BEGIN:DAYLIGHT
TZOFFSETFROM:+0200
TZOFFSETTO:+0300
TZNAME:EEST
DTSTART:19700329T030000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0300
TZOFFSETTO:+0200
TZNAME:EET
DTSTART:19701025T040000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE

I need to extract valuable for me part: event's DTSTART, DTEND, RRULE, and other iCaledar's field. Is there an existent solution for doing this?

like image 489
cleg Avatar asked Jul 09 '26 03:07

cleg


2 Answers

You can try the fantastic library python-dateutil (http://labix.org/python-dateutil).

like image 120
Antonio Beamud Avatar answered Jul 10 '26 18:07

Antonio Beamud


I'm using mxm's icalendar package:

http://codespeak.net/icalendar/

and I'm pretty sure it passes all ical fields to parsed objects. I'm not sure about reoccurence because I just don't use that in my app, but I would be surprised to find out it's not there.

like image 26
GDR Avatar answered Jul 10 '26 19:07

GDR