diff --git a/index.php b/index.php index 08ccef2..af64378 100644 --- a/index.php +++ b/index.php @@ -63,7 +63,7 @@ function findNext($start, $frequency, $excludes = [], $vsNow = true, $maxIterati return $current; } -function findPrevious($start, $frequency, $excludes = [], $nsNow = true, $maxIterations = 1000) { +function findPrevious($start, $frequency, $excludes = [], $vsNow = true, $maxIterations = 1000) { return findNext($start, $frequency, $excludes, $vsNow, $maxIterations, -1); } @@ -175,12 +175,12 @@ if (!$isConfig and $hasSupplier) { $start = new \DateTime($config[$supplier]['start']); if (!$hasEvent) { - $next = findNext($start, $config[$supplier]['frequency'], $config[$supplier]['excludes']); + $next = findNext($start, $config[$supplier]['frequency'], $config[$supplier]['excludes'], true); $nextEvent = $next->format('Y-m-d'); header('Location: ' . generateUrl($supplier, $nextEvent)); die(); } else { - $current = new \DateTimeImmutable($event); + $current = new \DateTime($event); $previous = findPrevious($current, $config[$supplier]['frequency'], $config[$supplier]['excludes'], false); $previousEvent = $previous->format('Y-m-d'); if (false and !array_key_exists($previousEvent, $data[$supplier]))