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

Removing all dates that are inside a DatePeriod from Rset #138

Open
cubecleveland opened this issue Sep 4, 2023 · 1 comment
Open

Removing all dates that are inside a DatePeriod from Rset #138

cubecleveland opened this issue Sep 4, 2023 · 1 comment

Comments

@cubecleveland
Copy link

cubecleveland commented Sep 4, 2023

Thank you so much for this amazing Library.

We have a use case where i want to remove all the dates that are present inside an RSet giving a period of time.

For example a new DatePeriod() object giving a start and end. i want to then remove all the dates from the Rset.
At first we thought we could use addExDate but this doesnt work, because apperantly u have to have the exact date and not just the date to remove..

To clarfiy, i dont have the exact timestamp of the Dates inside Rset , but i do want to remove all the dates that are inside the DatePeriod.
Can i manually iterate Rset and remove the dates.. wasnt sure it is the expected behavior/...

Any help would be appreciated and many thanks again for your hard work

@rlanvin
Copy link
Owner

rlanvin commented Sep 5, 2023

Hello, that's a good question. Indeed ExDate must match single occurrences, so it's not necessarily practical for the use case you describe. There is no such thing if the RFC to exclude a period like you describe, so it's not a feature that I implemented. For now I could think of possible workarounds:

  • You could use a ExRule with the exact same rule, only with a different DTSTART and with a UNTIL date. That rule will generate the occurrences to be excluded. Technically a ExRule could even be another RSet if you have complex rule.
  • Split your rules or RSet: make one with a UNTIL corresponding to the start of your blacklisted period, and another one starting at the end of your blacklisted period, so no occurrences would be generated during the exclusion period (you can put those two split rules inside a RSet and it would be transparent)
  • You could wrap the RSet in a proxy class that would filter out the occurrences you don't need based on simple date comparison before returning them.

I suppose it would also be possible to extend the library to support an exclusion period directly as part of RSet. If you want to work on a pull request go for it.

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

No branches or pull requests

2 participants