Skip to content

Composing multiple RDATE and RRULE properties #347

@brianmuse

Description

@brianmuse

I could be mistaken, but I believe that RFC5545 specifies that multiple RDATE properties may exist along with RRULE.

For example, this would be valid and would mean it recurs yearly and on those RDATE values:

RDATE:20160607T000000Z
RDATE:20160707T000000Z
RRULE:FREQ=YEARLY

Also, though it has SHOULD NOT guidance, you may also encounter multiple RRULE properties:

RDATE:20160607T000000Z
RDATE:20160707T000000Z
RRULE:FREQ=YEARLY
RRULE:FREQ=MONTHLY

It appears that both cannot be considered at the same time and that multiple are not supported:
https://github.com/fruux/sabre-vobject/blob/master/lib/Recur/EventIterator.php#L181-L190

        if (isset($this->masterEvent->RDATE)) {
            $this->recurIterator = new RDateIterator(
                $this->masterEvent->RDATE->getParts(),
                $this->startDate
            );
        } elseif (isset($this->masterEvent->RRULE)) {
            $this->recurIterator = new RRuleIterator(
                $this->masterEvent->RRULE->getParts(),
                $this->startDate
            );
        }

We have implemented this behavior before on another project and our technique (even supporting EXRULE) was to create an iterator for each RRULE, EXRULE and an iterator for RDATES and EXDATES and then compose result from iterating over all four of those one element at a time to get the "next" result (using logic to determine which event was actually next while handling any exceptions from EXRULE or EXDATE).

We used generators with PHP5.6, however iterators may be just as good in this case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions