/** * Expand the event instances for an RRULE property * * @param object $dtstart A RepeatRuleDateTime which is the master dtstart * @param string $property RDATE or EXDATE, depending... * @param array $component A vComponent which is a VEVENT, VTODO or VJOURNAL * @param array $range_end A date after which we care less about expansion * * @return array An array keyed on the UTC dates, referring to the component */ function rrule_expand($dtstart, $property, $component, $range_end) { $expansion = array(); $recur = $component->GetProperty($property); if (!isset($recur)) { return $expansion; } $recur = $recur->Value(); $this_start = $component->GetProperty('DTSTART'); if (isset($this_start)) { $timezone = $this_start->GetParameterValue('TZID'); $this_start = new RepeatRuleDateTime($this_start->Value(), $timezone); } else { $this_start = clone $dtstart; } // print_r( $this_start ); // printf( "RRULE: %s\n", $recur ); $rule = new RepeatRule($this_start, $recur); $i = 0; $result_limit = 1000; while ($date = $rule->next()) { // printf( "[%3d] %s\n", $i, $date->UTC() ); $expansion[$date->UTC()] = $component; if ($i++ >= $result_limit || $date > $range_end) { break; } } // print_r( $expansion ); return $expansion; }