Browse Source

tente de corriger un bug dans le calcul des dates adjecentes

master
vince vince 3 years ago
parent
commit
bde5121eb3
1 changed files with 17 additions and 9 deletions
  1. +17
    -9
      index.php

+ 17
- 9
index.php View File

@ -37,19 +37,27 @@ function findNext($start, $frequency, $excludes = [], $vsNow = true, $maxIterati
$frequency = \DateInterval::createFromDateString($frequency);
do {
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 {
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');
} while (
!in_array($nextEvent, $excludes)
in_array($nextEvent, $excludes)
and ($maxIterations > 0)
);
return $current;


Loading…
Cancel
Save