Date.php in Zircon Profile 8.0
Same filename in this branch
- 8.0 vendor/symfony/validator/Constraints/Date.php
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php
- 8.0 core/lib/Drupal/Core/Render/Element/Date.php
- 8.0 core/modules/views/src/Plugin/views/filter/Date.php
- 8.0 core/modules/views/src/Plugin/views/sort/Date.php
- 8.0 core/modules/views/src/Plugin/views/argument/Date.php
- 8.0 core/modules/views/src/Plugin/views/field/Date.php
- 8.0 core/modules/datetime/src/Plugin/views/filter/Date.php
- 8.0 core/modules/datetime/src/Plugin/views/sort/Date.php
- 8.0 core/modules/datetime/src/Plugin/views/argument/Date.php
Same filename and directory in other branches
Contains \Drupal\datetime\Plugin\views\sort\Date.
Namespace
Drupal\datetime\Plugin\views\sortFile
core/modules/datetime/src/Plugin/views/sort/Date.phpView source
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\views\sort\Date.
*/
namespace Drupal\datetime\Plugin\views\sort;
use Drupal\views\Plugin\views\sort\Date as NumericDate;
/**
* Basic sort handler for datetime fields.
*
* This handler enables granularity, which is the ability to make dates
* equivalent based upon nearness.
*
* @ViewsSort("datetime")
*/
class Date extends NumericDate {
/**
* Override to account for dates stored as strings.
*/
public function getDateField() {
// Return the real field, since it is already in string format.
return "{$this->tableAlias}.{$this->realField}";
}
/**
* Override query to provide 'second' granularity.
*/
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();
}
/**
* {@inheritdoc}
*
* Overridden in order to pass in the string date flag.
*/
public function getDateFormat($format) {
return $this->query
->getDateFormat($this
->getDateField(), $format, TRUE);
}
}