Skip to content

Commit

Permalink
Fix advanced search time
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Mar 14, 2020
1 parent e43a285 commit 7ca853d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/SaitoSearch/src/Controller/SearchesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public function advanced()

$queryData = $this->request->getQueryParams();

$now = Chronos::now();

/// Setup time filter data
$first = $this->Entries->find()
->order(['id' => 'ASC'])
Expand All @@ -135,7 +137,7 @@ public function advanced()
$defaultDate = $startDate < $aYearAgo ? $aYearAgo : $startDate;
} else {
/// No entries yet
$startDate = $defaultDate = Chronos::now();
$startDate = $defaultDate = $now;
}
$startYear = $startDate->format('Y');

Expand All @@ -161,7 +163,7 @@ public function advanced()

/// Time filter
$time = Chronos::createFromDate($year, $month, 1);
if ($time->year !== $defaultDate->year || $time->month !== $defaultDate->month) {
if ($now->year !== $defaultDate->year || $now->month !== $defaultDate->month) {
$query->where(['time >=' => $time]);
}

Expand Down

0 comments on commit 7ca853d

Please sign in to comment.