function Date::opSimple

Same name in this branch
  1. 10 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
Same name in other branches
  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()
  3. 8.9.x core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
  4. 8.9.x core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()
  5. 11.x core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
  6. 11.x 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}");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.