Rework RecurrenceId to use date/datetime and range #513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my suggestion for improving recurrence-id serializing/parsing #278. It now works with dates and supports RANGE as well (although it doesn't enumerate correctly yet in
timespan).A number of tests still need to be updated, some are just the snapshots but others should probably get this functionality confirmed before we change them.
Thank you for this library!
https://datatracker.ietf.org/doc/html/rfc5545#autoid-93
In short, the RFC states that Recurrence ID has a value of type
DATEorDATE-TIME(same value type as the event'sdtstart/dtend). ThisDATE/DATE-TIMEmust match an instance of the event within the recurrence, and it will override that one. Recurrence ID also has a few optional parameters:VALUEwhich can explicitly state whether it isDATEorDATE-TIME, the TZID timezone (similar to otherDATE-TIMEproperties), andRANGE, which only has one valid value,THISANDFUTURE, and signals this override should also apply to all additional following instances of the event.Here's an example giving all optional parameters
Prior to this PR,
RecurrenceIdcould not set the parameters, only the value, and the input type was a string instead of date/datetime. While one could potentially format at least the date value correctly on their own, there was no way to set the timezone for that date or enableTHISANDFUTURErange. Anecdotally, this caused a lot of confusion for me using the library about what sort of value I needed to provide, and was an issue because my use case depends on Recurrence ID heavily.This PR reworks
RecurrenceIdinto a Pydantic model with two fields:datewhich accepts either adateordatetimeobject, andthis_and_future, which is a boolean and addsRANGE=THISANDFUTUREto the params. The model now both parses and encodes these as well.This was proposed to get an idea of whether this was the right way to implement it, but it's incomplete and requires some additional changes:
RecurrenceIdcorrectly, particularly ontimespanTHISANDFUTURErangeRecurrenceId's type matchesdtstarton the eventRecurrenceId's date matches a time given by the recurrence rule.rruleandrecurrence-idare not both populated on the same event. (Saw an offhand comment about this but need stronger confirmation from the spec this is necessary)