Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno committed Oct 25, 2016
1 parent ec998c3 commit 204c6e7
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,25 @@ public function getNextSchedules( $fromDateStr = 'now', $limit = 5 )
foreach ($this->schedules as $schedule) {
$d = new \DateTime($fromDateStr);

for ($i=0, $maxRecursion = 10 * $limit; $i < $limit && $maxRecursion > 0; ++$i, --$maxRecursion) {
for ($i=0, $maxRecursion = 100 * $limit; $i < $limit && $maxRecursion > 0; ++$i, --$maxRecursion) {

if (strpos($schedule, '+') === false) {
$d->modify($schedule);
if ($this->isInTimeFrame($d, $fromDateStr)) {
$dates[] = clone $d;
}
}
else {
if (strpos($schedule, '+') !== false) {
if ($this->startTime instanceof \DateTime && $d < $this->startTime->modify($d->format('Y-m-d'))) {
$d->modify($this->startTime->format('H:i:s'));
}

if ($this->endTime instanceof \DateTime && $d > $this->endTime->modify($d->format('Y-m-d'))) {
$d->modify("next day 00:00:00");
elseif ($this->endTime instanceof \DateTime && $d > $this->endTime->modify($d->format('Y-m-d'))) {
$d->modify('next day')->modify($this->startTime->format('H:i:s'));
}

if ($this->isInTimeFrame($d, $fromDateStr)) {
$dates[] = clone $d;
}
$dates[] = clone $d;
$d->modify($schedule);
}
elseif ($this->isInTimeFrame($d->modify($schedule), $fromDateStr)) {
$dates[] = clone $d;
}
else {
--$i;
}
}
}

Expand Down Expand Up @@ -161,4 +158,4 @@ private function isInTimeFrame(\DateTime $date, $fromDateStr = 'now')
return true;
}

}
}

0 comments on commit 204c6e7

Please sign in to comment.