You are here

protected function Date::opSimple in Drupal 9

Same name in this branch
  1. 9 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
  2. 9 core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()
Same name and namespace in other branches
  1. 8 core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()

Override parent method, which deals with dates as integers.

Overrides Date::opSimple

File

core/modules/datetime/src/Plugin/views/filter/Date.php, line 128

Class

Date
Date/time views filter.

Namespace

Drupal\datetime\Plugin\views\filter

Code

protected function opSimple($field) {
  $timezone = $this
    ->getTimezone();
  $origin_offset = $this
    ->getOffset($this->value['value'], $timezone);

  // Convert to ISO. UTC timezone is used since dates are stored in UTC.
  $value = new DateTimePlus($this->value['value'], new \DateTimeZone($timezone));
  $value = $this->query
    ->getDateFormat($this->query
    ->getDateField("'" . $this->dateFormatter
    ->format($value
    ->getTimestamp() + $origin_offset, 'custom', DateTimeItemInterface::DATETIME_STORAGE_FORMAT, DateTimeItemInterface::STORAGE_TIMEZONE) . "'", TRUE, $this->calculateOffset), $this->dateFormat, TRUE);

  // This is safe because we are manually scrubbing the value.
  $field = $this->query
    ->getDateFormat($this->query
    ->getDateField($field, TRUE, $this->calculateOffset), $this->dateFormat, TRUE);
  $this->query
    ->addWhereExpression($this->options['group'], "{$field} {$this->operator} {$value}");
}