2c8338ad259945bc72f94278c3b2669a9995ca26
[yaffs-website] / src / Plugin / views / sort / Date.php
1 <?php
2
3 namespace Drupal\datetime\Plugin\views\sort;
4
5 use Drupal\views\Plugin\views\sort\Date as NumericDate;
6
7 /**
8  * Basic sort handler for datetime fields.
9  *
10  * This handler enables granularity, which is the ability to make dates
11  * equivalent based upon nearness.
12  *
13  * @ViewsSort("datetime")
14  */
15 class Date extends NumericDate {
16
17   /**
18    * Override to account for dates stored as strings.
19    */
20   public function getDateField() {
21     // Return the real field, since it is already in string format.
22     return "$this->tableAlias.$this->realField";
23   }
24
25   /**
26    * {@inheritdoc}
27    *
28    * Overridden in order to pass in the string date flag.
29    */
30   public function getDateFormat($format) {
31     return $this->query->getDateFormat($this->getDateField(), $format, TRUE);
32   }
33
34 }