You are here

function Date::op_between in Views (for Drupal 7) 8.3

Overrides Numeric::op_between

File

lib/Drupal/views/Plugin/views/filter/Date.php, line 169
Definition of Drupal\views\Plugin\views\filter\Date.

Class

Date
Filter to handle dates stored as a timestamp.

Namespace

Drupal\views\Plugin\views\filter

Code

function op_between($field) {
  $a = intval(strtotime($this->value['min'], 0));
  $b = intval(strtotime($this->value['max'], 0));
  if ($this->value['type'] == 'offset') {
    $a = '***CURRENT_TIME***' . sprintf('%+d', $a);

    // keep sign
    $b = '***CURRENT_TIME***' . sprintf('%+d', $b);

    // keep sign
  }

  // This is safe because we are manually scrubbing the values.
  // It is necessary to do it this way because $a and $b are formulas when using an offset.
  $operator = strtoupper($this->operator);
  $this->query
    ->add_where_expression($this->options['group'], "{$field} {$operator} {$a} AND {$b}");
}