diff --git a/core/modules/datetime/src/Plugin/views/filter/Date.php b/core/modules/datetime/src/Plugin/views/filter/Date.php index df542b0..136f8ff 100644 --- a/core/modules/datetime/src/Plugin/views/filter/Date.php +++ b/core/modules/datetime/src/Plugin/views/filter/Date.php @@ -35,13 +35,10 @@ class Date extends NumericDate { * Override parent method, which deals with dates as integers. */ protected function opBetween($field) { - $a = intval(strtotime($this->value['min'], 0)); - $b = intval(strtotime($this->value['max'], 0)); + $origin = ($this->value['type'] == 'offset') ? REQUEST_TIME : 0; + $a = intval(strtotime($this->value['min'], $origin)); + $b = intval(strtotime($this->value['max'], $origin)); - if ($this->value['type'] == 'offset') { - $a = REQUEST_TIME + $a; - $b = REQUEST_TIME + $b; - } // Convert to ISO format and format for query. $a = $this->query->getDateFormat("'" . format_date($a, 'custom', 'c') . "'", static::$dateFormat, TRUE); $b = $this->query->getDateFormat("'" . format_date($b, 'custom', 'c') . "'", static::$dateFormat, TRUE); @@ -56,10 +53,9 @@ protected function opBetween($field) { * Override parent method, which deals with dates as integers. */ protected function opSimple($field) { - $value = intval(strtotime($this->value['value'], 0)); - if (!empty($this->value['type']) && $this->value['type'] == 'offset') { - $value = REQUEST_TIME + $value; - } + $origin = (!empty($this->value['type']) && $this->value['type'] == 'offset') ? REQUEST_TIME : 0; + $value = intval(strtotime($this->value['value'], $origin)); + // Convert to ISO. $value = $this->query->getDateFormat("'" . format_date($value, 'custom', 'c') . "'", static::$dateFormat, TRUE);