Search code examples
pythonicalendar

how to add rrule to icalendar event in python?


I am trying to create simple recurring events in Python with icalendar

from icalendar import Event
from datetime import datetime
ev = Event()
ev.add('dtstart', datetime(2013,11,22,8))
ev.add('dtend', datetime(2013,11,22,12))
ev.add('rrule', 'freq=daily')

I have got this exception : ValueError: dictionary update sequence element #0 has length 1; 2 is required on the last line (the one with 'rrule')

Any thoughts ? I checked the ical doc but they don't have many python examples


Solution

  • Looking at src/icalendar/tests/test_timezoned.py:

     tzs.add('rrule', {'freq': 'yearly', 'bymonth': 10, 'byday': '-1su'})
     # event.add('rrule', u'FREQ=YEARLY;INTERVAL=1;COUNT=10)
    

    So they must have changed their format to a dictionary instead

    ev.add('rrule', {'freq': 'daily'})
    

    works