Skip to content

Commit

Permalink
Enhance recurrence rule logic to handle EXDATE data when a count is…
Browse files Browse the repository at this point in the history
… imposed
  • Loading branch information
u01jmg3 committed Dec 16, 2016
1 parent 93ee33e commit b7b3ee6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,14 @@ public function processRecurrences()
// Get Until
$until = strtotime($rrules['UNTIL']);
} else if (isset($rrules['COUNT'])) {
$countOrig = (is_numeric($rrules['COUNT']) && $rrules['COUNT'] > 1) ? $rrules['COUNT'] : 0;
$count = ($countOrig - 1); // Remove one to exclude the occurrence that initialises the rule
$countOrig = (is_numeric($rrules['COUNT']) && $rrules['COUNT'] > 1) ? $rrules['COUNT'] : 0;

// Increment count by the number of excluded dates
$countOrig += (isset($anEvent['EXDATE'])) ? sizeof($anEvent['EXDATE_array'][1]) : 0;

// Remove one to exclude the occurrence that initialises the rule
$count = ($countOrig - 1);

$count += ($count > 0) ? $count * ($interval - 1) : 0;
$countNb = 1;
$offset = "+$count " . $this->frequencyConversion[$frequency];
Expand Down

0 comments on commit b7b3ee6

Please sign in to comment.