Skip to content

Commit

Permalink
refactor original start time calculation into startTime method
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed May 30, 2024
1 parent 102909e commit 85d72e0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/Recur/RRuleIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ public function fastForward(\DateTimeInterface $dt): void

/* Functions that advance the iterator {{{ */

/**
* Gets the original start time of the RRULE.
*
* The value is formatted as a string with 24-hour:minute:second
*/
protected function startTime(): string
{
return $this->startDate->format('H:i:s');
}

/**
* Advances currentDate by the interval.
* The time is set from the original startDate.
Expand All @@ -295,7 +305,7 @@ public function fastForward(\DateTimeInterface $dt): void
*/
protected function advanceTheDate(string $interval): void
{
$this->currentDate = $this->currentDate->modify($interval.' '.$this->startDate->format('H:i:s'));
$this->currentDate = $this->currentDate->modify($interval.' '.$this->startTime());
}

/**
Expand Down Expand Up @@ -465,7 +475,7 @@ protected function nextMonthly(): void
do {
++$increase;
$tempDate = clone $this->currentDate;
$tempDate = $tempDate->modify('+ '.($this->interval * $increase).' months '.$this->startDate->format('H:i:s'));
$tempDate = $tempDate->modify('+ '.($this->interval * $increase).' months '.$this->startTime());
} while ($tempDate->format('j') != $currentDayOfMonth);
$this->currentDate = $tempDate;
}
Expand Down Expand Up @@ -524,7 +534,7 @@ protected function nextMonthly(): void
(int) $this->currentDate->format('Y'),
(int) $this->currentDate->format('n'),
(int) $occurrence
)->modify($this->startDate->format('H:i:s'));
)->modify($this->startTime());
}

/**
Expand Down

0 comments on commit 85d72e0

Please sign in to comment.