Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jul 21, 2021
1 parent 396e31c commit b7d95a0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Filter/AbstractDateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,18 @@ final protected function filter(ProxyQueryInterface $query, string $field, Filte
return;
}

\assert($value instanceof \DateTime || $value instanceof \DateTimeImmutable);

//default type for simple filter
$type = $data->getType() ?? DateOperatorType::TYPE_EQUAL;

// date filter should filter records for the whole day
if (false === $this->time && DateOperatorType::TYPE_EQUAL === $type) {
$endValue = clone $value;
$endValue = $endValue->add(new \DateInterval('P1D'));
if ($value instanceof \DateTime) {
$endValue = clone $value;
$endValue->add(new \DateInterval('P1D'));
} else {
/** @var \DateTimeImmutable $value */
$endValue = $value->add(new \DateInterval('P1D'));
}

$this->applyType($query, $this->getOperator(DateOperatorType::TYPE_GREATER_EQUAL), $field, $value);
$this->applyType($query, $this->getOperator(DateOperatorType::TYPE_LESS_THAN), $field, $endValue);
Expand Down

0 comments on commit b7d95a0

Please sign in to comment.