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/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()

Overrides NumericFilter::opSimple

1 method overrides Date::opSimple()
Date::opSimple in core/modules/datetime/src/Plugin/views/filter/Date.php
Override parent method, which deals with dates as integers.

File

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

Class

Date
Filter to handle dates stored as a timestamp.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function opSimple($field) {
  $value = intval(strtotime($this->value['value'], 0));
  if (!empty($this->value['type']) && $this->value['type'] == 'offset') {

    // Keep sign.
    $value = '***CURRENT_TIME***' . sprintf('%+d', $value);
  }

  // This is safe because we are manually scrubbing the value.
  // It is necessary to do it this way because $value is a formula when using an offset.
  $this->query
    ->addWhereExpression($this->options['group'], "{$field} {$this->operator} {$value}");
}