Expand RFC-2445 (iCalendar) recurrence rule?

R

Roy Smith

Does there exist a stand-alone module to expand RFC-2445 recurrence
rule? The idea is to start with a string like:

"RRULE:FREQ=WEEKLY;COUNT=6;INTERVAL=2;BYDAY=FR"

and derive a list of dates on which that event occurs.

I'm aware of http://codespeak.net/icalendar/, but that solves a much
larger problem (parsing ics files) and I can't see how to tease out just
this one function from that module.
 
R

Roy Smith

O.B. Murithi suggested I look at http://labix.org/python-dateutil, which turns out to have exactly what I'm looking for. Thanks!

from dateutil.rrule import rrulestr
from dateutil.parser import parse

rule = rrulestr("FREQ=WEEKLY;COUNT=6;INTERVAL=2;BYDAY=FR",
dtstart=parse("2012-06-15"))
for date in rule:
print date

../rrule.py
2012-06-15 00:00:00
2012-06-29 00:00:00
2012-07-13 00:00:00
2012-07-27 00:00:00
2012-08-10 00:00:00
2012-08-24 00:00:00
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top