diff --git a/core/modules/datetime/src/Plugin/views/sort/Date.php b/core/modules/datetime/src/Plugin/views/sort/Date.php index b86d424..12eddc6 100644 --- a/core/modules/datetime/src/Plugin/views/sort/Date.php +++ b/core/modules/datetime/src/Plugin/views/sort/Date.php @@ -43,4 +43,14 @@ public function query() { 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); + } + + } diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index f03b494..61d5ce8 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -1833,15 +1833,19 @@ public function getDateFormat($field, $format, $string_date = FALSE) { 'A' => '', ); $format = strtr($format, $replace); + + // Don't use the 'unixepoch' flag for string date comparisons. + $unixepoch = $string_date ? '' : ", 'unixepoch'"; + // SQLite does not have a ISO week substitution string, so it needs // special handling. // @see http://en.wikipedia.org/wiki/ISO_week_date#Calculation // @see http://stackoverflow.com/a/15511864/1499564 if ($format === '%W') { - $expression = "((strftime('%j', date(strftime('%Y-%m-%d', $field, 'unixepoch'), '-3 days', 'weekday 4')) - 1) / 7 + 1)"; + $expression = "((strftime('%j', date(strftime('%Y-%m-%d', $field" . $unixepoch . "), '-3 days', 'weekday 4')) - 1) / 7 + 1)"; } else { - $expression = "strftime('$format', $field, 'unixepoch')"; + $expression = "strftime('$format', $field" . $unixepoch . ")"; } // The expression yields a string, but the comparison value is an // integer in case the comparison value is a float, integer, or numeric.