You are here

public function Date::query in Zircon Profile 8.0

Same name in this branch
  1. 8.0 core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date::query()
  2. 8.0 core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date::query()
Same name and namespace in other branches
  1. 8 core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date::query()

Override query to provide 'second' granularity.

Overrides Date::query

File

core/modules/datetime/src/Plugin/views/sort/Date.php, line 33
Contains \Drupal\datetime\Plugin\views\sort\Date.

Class

Date
Basic sort handler for datetime fields.

Namespace

Drupal\datetime\Plugin\views\sort

Code

public function query() {
  $this
    ->ensureMyTable();
  switch ($this->options['granularity']) {
    case 'second':
      $formula = $this
        ->getDateFormat('YmdHis');
      $this->query
        ->addOrderBy(NULL, $formula, $this->options['order'], $this->tableAlias . '_' . $this->field . '_' . $this->options['granularity']);
      return;
  }

  // All other granularities are handled by the numeric sort handler.
  parent::query();
}