You are here

protected function DatexViewsDateTime::opBetween in Datex 8

Override parent method, which deals with dates as integers.

Overrides Date::opBetween

File

src/Plugin/views/filter/DatexViewsDateTime.php, line 54

Class

DatexViewsDateTime
Filter to handle dates stored as a timestamp.

Namespace

Drupal\datex\Plugin\views\filter

Code

protected function opBetween($field) {
  $this->value['min'] = DatexArgHandlerTrait::translate($this->value['min']);
  $this->value['max'] = DatexArgHandlerTrait::translate($this->value['max']);
  $cal = datex_factory();
  if ($cal) {
    if ($cal
      ->parse($this->value['min'], 'Y-m-d H:i:s')) {
      $this->value['min'] = $cal
        ->xFormat('Y-m-d H:i:s');
    }
    elseif ($cal
      ->parse($this->value['min'], 'Y-m-d')) {
      $this->value['min'] = $cal
        ->xFormat('Y-m-d');
    }
    else {
      $this->value['min'] = \Drupal::time()
        ->getRequestTime();
    }
    if ($cal
      ->parse($this->value['max'], 'Y-m-d H:i:s')) {
      $this->value['max'] = $cal
        ->xFormat('Y-m-d H:i:s');
    }
    elseif ($cal
      ->parse($this->value['max'], 'Y-m-d')) {
      $this->value['max'] = $cal
        ->xFormat('Y-m-d');
    }
    else {
      $this->value['max'] = \Drupal::time()
        ->getRequestTime();
    }
  }
  parent::opBetween($field);
}