diff --git a/core/modules/datetime/src/Plugin/views/filter/Date.php b/core/modules/datetime/src/Plugin/views/filter/Date.php index e862aa4..807e166 100644 --- a/core/modules/datetime/src/Plugin/views/filter/Date.php +++ b/core/modules/datetime/src/Plugin/views/filter/Date.php @@ -212,8 +212,14 @@ protected function opSimple($field) { $timezone = $this->getTimezone(); $origin_offset = $this->getOffset($this->value['value'], $timezone); + // Accommodate input with year-level granularity. + $date_value = $this->value['value']; + if ($this->options['granularity'] == 'year') { + $date_value = preg_replace('/^(\d{4})$/', '$1-01-01', $date_value); + } + // Convert to ISO. UTC timezone is used since dates are stored in UTC. - $value = new DateTimePlus($this->value['value'], new \DateTimeZone($timezone)); + $value = new DateTimePlus($date_value, new \DateTimeZone($timezone)); $value = $this->query->getDateFormat($this->query->getDateField("'" . $this->dateFormatter->format($value->getTimestamp() + $origin_offset, 'custom', DateTimeItemInterface::DATETIME_STORAGE_FORMAT, DateTimeItemInterface::STORAGE_TIMEZONE) . "'", TRUE, $this->calculateOffset), $this->dateFormat, TRUE); // This is safe because we are manually scrubbing the value.