Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python dateutils print recurrence rule according to iCalendar format (see RFC 5545)

I am trying to print a recurrence rule as a string specified by iCalendar format (see RFC 5545). Im using python dateutils, in particular dateutil.rrule to create the recurrence rule and I want to print this as a string like:

    "RRULE:FREQ=DAILY;COUNT=5"

Can anyone tell me if there is a method to achieve this?

I think I'm using the labix dateutils btw.

Many thanks!

like image 837
user1656817 Avatar asked Sep 08 '12 14:09

user1656817


2 Answers

Although this is written four years after the question was asked, dateutil by now has a __str__ method (see source code) which allows one to print its objects in such a form:

In [1]: from dateutil.rrule import *

In [2]: my_rrule = rrule(DAILY, count=5)

In [3]: print(my_rrule)
DTSTART:20161202T184513
FREQ=DAILY;COUNT=5
like image 22
Kurt Peek Avatar answered Oct 20 '22 12:10

Kurt Peek


There is no method or function in the python-dateutil package to do this. See this bug for a patch that may help: https://bugs.launchpad.net/dateutil/+bug/943512.

like image 182
Pedro Romano Avatar answered Oct 20 '22 12:10

Pedro Romano