Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
u01jmg3 committed Sep 2, 2019
1 parent f551c3b commit e0e1b83
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1309,12 +1309,15 @@ protected function processRecurrences()
break;

case 'WEEKLY':
$matchingDays = array($frequencyRecurringDateTime->format('N'));
$initialDayOfWeek = $frequencyRecurringDateTime->format('N');
$matchingDays = array($initialDayOfWeek);

if (!empty($rrules['BYDAY'])) {
// setISODate below uses the ISO-8601 specification of weeks: start on
// setISODate() below uses the ISO-8601 specification of weeks: start on
// a Monday, end on a Sunday. However, RRULEs (or the caller of the
// parser) may state an alternate WeeKSTart.
$wkstTransition = 7;

if (empty($rrules['WKST'])) {
if ($this->defaultWeekStart !== self::ISO_8601_WEEK_START) {
$wkstTransition = array_search($this->defaultWeekStart, array_keys($this->weekdays));
Expand All @@ -1323,10 +1326,10 @@ protected function processRecurrences()
$wkstTransition = array_search($rrules['WKST'], array_keys($this->weekdays));
}

$initialDayOfWeek = $frequencyRecurringDateTime->format('N');
$matchingDays = array_map(
function ($weekday) use ($interval, $wkstTransition, $initialDayOfWeek) {
function ($weekday) use ($initialDayOfWeek, $wkstTransition, $interval) {
$day = array_search($weekday, array_keys($this->weekdays));

if ($day < $initialDayOfWeek) {
$day += 7;
}
Expand All @@ -1336,10 +1339,12 @@ function ($weekday) use ($interval, $wkstTransition, $initialDayOfWeek) {
}

// Ignoring alternate week starts, $day at this point will have a
// value between 0 and 6. But setISODate expects a value 1 to 7.
// value between 0 and 6. But setISODate() expects a value of 1 to 7.
// Even with alternate week starts, we still need to +1 to set the
// correct weekday.
return $day + 1;
$day += 1;

return $day;
},
$rrules['BYDAY']
);
Expand All @@ -1355,7 +1360,6 @@ function ($weekday) use ($interval, $wkstTransition, $initialDayOfWeek) {
$day
);
}

break;

case 'MONTHLY':
Expand Down Expand Up @@ -1384,7 +1388,6 @@ function ($weekday) use ($interval, $wkstTransition, $initialDayOfWeek) {
$day
);
}

break;

case 'YEARLY':
Expand Down Expand Up @@ -1417,7 +1420,6 @@ function ($weekday) use ($interval, $wkstTransition, $initialDayOfWeek) {
} else {
$candidateDateTimes[] = clone $frequencyRecurringDateTime;
}

break;
}

Expand Down

0 comments on commit e0e1b83

Please sign in to comment.