|
@ -37,19 +37,27 @@ function findNext($start, $frequency, $excludes = [], $vsNow = true, $maxIterati |
|
|
$frequency = \DateInterval::createFromDateString($frequency); |
|
|
$frequency = \DateInterval::createFromDateString($frequency); |
|
|
do { |
|
|
do { |
|
|
if ($direction === abs($direction)) { |
|
|
if ($direction === abs($direction)) { |
|
|
while ( |
|
|
|
|
|
(!$vsNow or ($current->getTimestamp() < $now->getTimestamp())) |
|
|
|
|
|
and ($maxIterations-- > 0) |
|
|
|
|
|
) $current->add($frequency); |
|
|
|
|
|
|
|
|
if (!$vsNow and ($maxIterations-- > 0)) { |
|
|
|
|
|
$current->add($frequency); |
|
|
|
|
|
} else { |
|
|
|
|
|
while ( |
|
|
|
|
|
($current->getTimestamp() < $now->getTimestamp()) |
|
|
|
|
|
and ($maxIterations-- > 0) |
|
|
|
|
|
) $current->add($frequency); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
while ( |
|
|
|
|
|
(!$vsNow or ($current->getTimestamp() > $now->getTimestamp())) |
|
|
|
|
|
and ($maxIterations-- > 0) |
|
|
|
|
|
) $current->sub($frequency); |
|
|
|
|
|
|
|
|
if (!$vsNow and ($maxIterations-- > 0)) { |
|
|
|
|
|
$current->sub($frequency); |
|
|
|
|
|
} else { |
|
|
|
|
|
while ( |
|
|
|
|
|
($current->getTimestamp() > $now->getTimestamp()) |
|
|
|
|
|
and ($maxIterations-- > 0) |
|
|
|
|
|
) $current->sub($frequency); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
$nextEvent = $current->format('Y-m-d'); |
|
|
$nextEvent = $current->format('Y-m-d'); |
|
|
} while ( |
|
|
} while ( |
|
|
!in_array($nextEvent, $excludes) |
|
|
|
|
|
|
|
|
in_array($nextEvent, $excludes) |
|
|
and ($maxIterations > 0) |
|
|
and ($maxIterations > 0) |
|
|
); |
|
|
); |
|
|
return $current; |
|
|
return $current; |
|
|