From 82ee4e90c20e4f1575f43af6b769bdcf60a8061f Mon Sep 17 00:00:00 2001 From: Cyril van Schreven Date: Mon, 22 Apr 2024 12:46:46 +0200 Subject: [PATCH] Do not apply workaround on inner loops --- lib/Recur/RRuleIterator.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index f987e7929..a63268b66 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -440,7 +440,7 @@ private function jumpForward(\DateTimeInterface $dt): void */ protected function nextHourly($amount = 1): void { - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+'.$amount * $this->interval.' hours'); + $this->currentDate = $this->currentDate->modify('+'.$amount * $this->interval.' hours'); } /** @@ -473,13 +473,13 @@ protected function nextDaily($amount = 1): void if ($this->byHour) { if ('23' == $this->currentDate->format('G')) { // to obey the interval rule - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+'.(($amount * $this->interval) - 1).' days'); + $this->currentDate = $this->currentDate->modify('+'.(($amount * $this->interval) - 1).' days'); $amount = 1; } - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+1 hours'); + $this->currentDate = $this->currentDate->modify('+1 hours'); } else { - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+'.($amount * $this->interval).' days'); + $this->currentDate = $this->currentDate->modify('+'.($amount * $this->interval).' days'); $amount = 1; } @@ -530,9 +530,9 @@ protected function nextWeekly($amount = 1): void do { if ($this->byHour) { - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+1 hours'); + $this->currentDate = $this->currentDate->modify('+1 hours'); } else { - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+1 days'); + $this->currentDate = $this->currentDate->modify('+1 days'); } // Current day of the week @@ -543,12 +543,12 @@ protected function nextWeekly($amount = 1): void // We need to roll over to the next week if ($currentDay === $firstDay && (!$this->byHour || '0' == $currentHour)) { - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+'.(($amount * $this->interval) - 1).' weeks'); + $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 // are not already on this first day of this week. if ($this->currentDate->format('w') != $firstDay) { - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, 'last '.$this->dayNames[$this->dayMap[$this->weekStart]]); + $this->currentDate = $this->currentDate->modify('last '.$this->dayNames[$this->dayMap[$this->weekStart]]); } } @@ -578,7 +578,7 @@ protected function nextMonthly($amount = 1): void do { ++$increase; $tempDate = clone $this->currentDate; - $tempDate = $this->getNextIterationDateTime($tempDate, '+ '.($this->interval * $increase).' months'); + $tempDate = $tempDate->modify('+ '.($this->interval * $increase).' months'); } while ($tempDate->format('j') != $currentDayOfMonth); $this->currentDate = $tempDate; } @@ -623,7 +623,7 @@ protected function nextMonthly($amount = 1): void 1 ); // end of workaround - $this->currentDate = $this->getNextIterationDateTime($this->currentDate, '+ '.($amount * $this->interval).' months'); + $this->currentDate = $this->currentDate->modify('+ '.($amount * $this->interval).' months'); $amount = 1; // This goes to 0 because we need to start counting at the @@ -684,7 +684,7 @@ protected function nextYearly($amount = 1): void // 400. (1800, 1900, 2100). So we just rely on the datetime // functions instead. $nextDate = clone $this->currentDate; - $nextDate = $this->getNextIterationDateTime($nextDate, '+ '.($this->interval * $counter).' years'); + $nextDate = $nextDate->modify('+ '.($this->interval * $counter).' years'); } while (2 != $nextDate->format('n')); $this->currentDate = $nextDate;