OzzyCzech / icalparser

Simple ical parser for PHP
https://ozana.cz
BSD 3-Clause "New" or "Revised" License
59 stars 22 forks source link

Two weekly recurrence rule does not function #61

Closed WimRaaij closed 1 year ago

WimRaaij commented 2 years ago

In my Google calender two different weekly events are scheduled. One event is on a tuesday every two weeks. The other event also but one week shifted. (Same starttime and endtime.) So, effectively the events alternate every week.

When i use icalparser both events are shown every thuesday. (Google calender shows the events correctly (alternating on tuesday). Any idea whats going wrong?

Example of one event: Thuesday event.txt

jaydenlo08 commented 2 years ago

Had the same problem while doing some project for my school. I solved it by changing line 453 of IcalParser to: foreach ($recurrences as $j => $recurDate) { if (isset($event['RRULE']['INTERVAL'])) { if ($event['DTSTART']->diff($recurDate)->format('%a') % $event['RRULE']['INTERVAL'] * 7 == 0) { $newEvent = $event; if (!$firstEvent) { unset($newEvent['RECURRENCES']); $newEvent['DTSTART'] = $recurDate; $newEvent['DTEND'] = clone($recurDate); $newEvent['DTEND']->add($eventInterval); }

        $newEvent['RECURRENCE_INSTANCE'] = $j;
        $events->append($newEvent);
        $firstEvent = false;
    }
}

}

WimRaaij commented 1 year ago

Thanks Christiaan and Ozzy,

The 'Weekly-recurrence-problem' is solved in this version!!