Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rrule from a string #758

Closed
fluxxcode opened this issue Dec 19, 2024 · 2 comments · Fixed by #759
Closed

Add rrule from a string #758

fluxxcode opened this issue Dec 19, 2024 · 2 comments · Fixed by #759

Comments

@fluxxcode
Copy link
Contributor

fluxxcode commented Dec 19, 2024

We have a rrule string that we want to add to an event.

At the moment this doesn't seem possible because the semicolons in the rrule strings are escaped with a backslash, invalidating the rrule.

Here is an example:

import icalendar

rrule_str = "FREQ=YEARLY;INTERVAL=10;BYMONTH=12"

event = Event()

# Both result in the same output
event.add("rrule", rrule_str)
event["rrule"] = rrule_str

Calling .to_ical escapes the rrule: RRULE:FREQ=YEARLY\;INTERVAL=10\;BYMONTH=12, making it invalid.

I think something like event.add_unescaped would be helpful.

@niccokunzmann
Copy link
Member

niccokunzmann commented Dec 20, 2024

Hi, thanks! It should somehow be possible to do that.

I would look for something like this:

from icalendar import vRecur

event["rrule"] = vRecur.from_ical("FREQ=YEARLY;INTERVAL=10;BYMONTH=12")

If you find a working example, could you add it to the documentation?
https://icalendar.readthedocs.io/en/latest/api.html#icalendar.prop.vRecur

I am sure others would like to use it, too..

@fluxxcode
Copy link
Contributor Author

fluxxcode commented Dec 21, 2024

Thank you for the answer!

event["rrule"] = vRecur.from_ical("FREQ=YEARLY;INTERVAL=10;BYMONTH=12")

works perfectly. I will create a PR for an example in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants