Skip to content

Commit

Permalink
Add testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
KAYLukas committed Dec 7, 2018
1 parent a00a460 commit 3f2279e
Show file tree
Hide file tree
Showing 3 changed files with 448 additions and 16 deletions.
29 changes: 14 additions & 15 deletions lib/Recur/RRuleIterator.php
Expand Up @@ -2,7 +2,6 @@

namespace Sabre\VObject\Recur;

use DateTimeImmutable;
use DateTimeInterface;
use Iterator;
use Sabre\VObject\DateTimeParser;
Expand Down Expand Up @@ -92,19 +91,19 @@ public function next($amount = 1)
// Otherwise, we find the next event in the normal RRULE
// sequence.
switch ($this->frequency) {
case 'hourly' :
case 'hourly':
$this->nextHourly($amount);
break;
case 'daily' :
case 'daily':
$this->nextDaily($amount);
break;
case 'weekly' :
case 'weekly':
$this->nextWeekly($amount);
break;
case 'monthly' :
case 'monthly':
$this->nextMonthly($amount);
break;
case 'yearly' :
case 'yearly':
$this->nextYearly($amount);
break;
}
Expand Down Expand Up @@ -135,19 +134,19 @@ public function fastForward(DateTimeInterface $dt)
do {
$diff = $this->currentDate->diff($dt);
switch ($this->frequency) {
case 'hourly' :
case 'hourly':
$i = $diff->days * 24;
break;
case 'daily' :
case 'daily':
$i = $diff->days;
break;
case 'weekly' :
case 'weekly':
$i = $diff->days / 7;
break;
case 'monthly' :
case 'monthly':
$i = $diff->days / 30;
break;
case 'yearly' :
case 'yearly':
$i = $diff->days / 365;
break;
}
Expand Down Expand Up @@ -403,10 +402,11 @@ protected function nextDaily($amount = 1)
/**
* Does the processing for advancing the iterator for weekly frequency.
*/
protected function nextWeekly($amount = 1) {
protected function nextWeekly($amount = 1)
{

if (!$this->byHour && !$this->byDay) {
$this->currentDate = $this->currentDate->modify('+' .($amount * $this->interval).' weeks');
$this->currentDate = $this->currentDate->modify('+'.($amount * $this->interval).' weeks');
return;
}

Expand Down Expand Up @@ -435,7 +435,7 @@ protected function nextWeekly($amount = 1) {
$currentHour = (int) $this->currentDate->format('G');

// We need to roll over to the next week
if ($currentDay === $firstDay && (!$this->byHour || $currentHour == '0')) {
if ($currentDay === $firstDay && (!$this->byHour || '0' == $currentHour)) {
$this->currentDate = $this->currentDate->modify('+'.(($amount * $this->interval) - 1).' weeks');
$amount = 1;
// We need to go to the first day of this week, but only if we
Expand Down Expand Up @@ -596,7 +596,6 @@ protected function nextYearly($amount = 1)

if (count($checkDates) > 0) {
$this->currentDate = min($checkDates);

return;
}

Expand Down

0 comments on commit 3f2279e

Please sign in to comment.