You are here

protected function CalendarSystemsViewsDateTime::opBetween in Calendar Systems 8.3

Override parent method, which deals with dates as integers.

Overrides Date::opBetween

File

src/Plugin/views/filter/CalendarSystemsViewsDateTime.php, line 56

Class

CalendarSystemsViewsDateTime
Filter to handle dates stored as a timestamp.

Namespace

Drupal\calendar_systems\Plugin\views\filter

Code

protected function opBetween($field) {
  $this->value['min'] = CalendarSystemsArgHandlerTrait::translate($this->value['min']);
  $this->value['max'] = CalendarSystemsArgHandlerTrait::translate($this->value['max']);
  $cal = _calendar_systems_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);
}