simshaun / recurr

PHP library for working with recurrence rules (RRULE); meant to help with recurring calendar events.
Other
1.21k stars 136 forks source link

EXDATE and EXRULE implementation #25

Closed DmitryVarennikov closed 10 years ago

DmitryVarennikov commented 10 years ago

According to the RFC 2445 there are EXDATE and EXRULE recurrence component properties which can be used in conjunction with RRULE to generate a recurrence set.

This will allow to create recurring events and then delete single instances from a series during generation.

If implementation of both is time-consuming I prefer to have at least EXDATE. What are your thoughts on it?

DmitryVarennikov commented 10 years ago

An example from python-dateutil

>>> set = rruleset()
>>> set.rrule(rrule(DAILY, count=7,
                    dtstart=parse("19970902T090000")))
>>> set.exrule(rrule(YEARLY, byweekday=(SA,SU),
                     dtstart=parse("19970902T090000")))
>>> list(set)
[datetime.datetime(1997, 9, 2, 9, 0),
 datetime.datetime(1997, 9, 3, 9, 0),
 datetime.datetime(1997, 9, 4, 9, 0),
 datetime.datetime(1997, 9, 5, 9, 0),
 datetime.datetime(1997, 9, 8, 9, 0)]
>>> set = rruleset()
>>> set.rrule(rrule(WEEKLY, count=4,
                    dtstart=parse("19970902T090000")))
>>> set.rdate(datetime.datetime(1997, 9, 7, 9, 0))
>>> set.exdate(datetime.datetime(1997, 9, 16, 9, 0))
>>> list(set)
[datetime.datetime(1997, 9, 2, 9, 0),
 datetime.datetime(1997, 9, 7, 9, 0),
 datetime.datetime(1997, 9, 9, 9, 0),
 datetime.datetime(1997, 9, 23, 9, 0)]
DmitryVarennikov commented 10 years ago

! Important

rfc 5545 is a new standard which obsoletes rfs 2445. The new standard says that "EXRULE" property can no longer be specified in a component. That means only EXDATE should be considered.

simshaun commented 10 years ago

Sounds like a good idea. I'll try to implement EXDATE this week. Shouldn't be difficult at all.

johnkary commented 10 years ago

+1 We are also looking to use this kind of feature very soon. We're ramping up on our calendaring/scheduling app and allowing exemptions in a recurring event is high on our priority list.

simshaun commented 10 years ago

Support for EXDATE added in b7003c5f7d.

johnkary commented 10 years ago

Thanks @simshaun! We'll put it to use and ping with any feedback or improvements.

brianmuse commented 8 years ago

Hey guys, EXRULE was indeed deprecated in RFC5545, however it still seems to be mentioned and is "allowed". It would be especially nice to support it considering a couple major calendar services still use it. For example many versions of Exchange / EWS still use RFC 2445 (since 5545 was ratified in 2009, it's still somewhat "new").

Even the latest version of the Google API says in their documentation:

List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545. Note that DTSTART and DTEND lines are not allowed in this field; event start and end times are specified in the start and end fields. This field is omitted for single events or instances of recurring events.

What are your thoughts on supporting this value, as it still seems to be fairly widely used and is not explicitly disallowed by the spec?