Recurring Events
Use dateutil.rrule to generate recurring date sequences (weekly, monthly, etc.) following the iCalendar RRULE spec.
Use dateutil.rrule to generate recurring date sequences (weekly, monthly, etc.) following the iCalendar RRULE spec.
from dateutil.rrule import rrule, WEEKLY, MO, WE, FR
from dateutil.parser import parse
meetings = list(rrule(
WEEKLY,
dtstart=parse("2024-01-01"),
until=parse("2024-03-31"),
byweekday=[MO, WE, FR],
))
print(f"{len(meetings)} meetings")
# Monthly on 15th
monthly = rrule(freq=rrule.MONTHLY, dtstart=parse("2024-01-15"), count=12, bymonthday=15)
rrule follows RFC 5545 — it handles DST transitions, end-of-month edge cases, and exclusions.