Skip to content

Instantly share code, notes, and snippets.

@ThiefMaster
Created May 18, 2011 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThiefMaster/978722 to your computer and use it in GitHub Desktop.
Save ThiefMaster/978722 to your computer and use it in GitHub Desktop.
monkey patch to make vRecur generate an apple iCal comaptible rrule string
class vRecur(icalendar.vRecur):
"""Fix vRecur so the frequency comes first"""
def ical(self):
# SequenceTypes
result = ['FREQ=%s' % self.types['FREQ'](self['FREQ']).ical()]
for key, vals in self.items():
if key == 'FREQ':
continue
typ = self.types[key]
if not type(vals) in icalendar.prop.SequenceTypes:
vals = [vals]
vals = ','.join([typ(val).ical() for val in vals])
result.append('%s=%s' % (key, vals))
return ';'.join(result)
icalendar.cal.types_factory['recur'] = vRecur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment