diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateRangePlainFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateRangePlainFormatter.php index 7b77a06..a2a1b13 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateRangePlainFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateRangePlainFormatter.php @@ -69,7 +69,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { */ protected function formatDate($date) { $format = $this->getFieldSetting('daterange_type') == DateRangeItem::DATERANGE_TYPE_DATE ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT; - $timezone = $this->getSetting('timezone_override'); + $timezone = $this->getSetting('timezone_override') ?: $date->getTimezone()->getName(); return $this->dateFormatter->format($date->getTimestamp(), 'custom', $format, $timezone != '' ? $timezone : NULL); } diff --git a/core/modules/datetime/src/Tests/DateRangeFieldTest.php b/core/modules/datetime/src/Tests/DateRangeFieldTest.php index b31e08d..1aa3775 100644 --- a/core/modules/datetime/src/Tests/DateRangeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateRangeFieldTest.php @@ -176,8 +176,7 @@ function testDateRangeField() { $this->assertRaw($end_date->format($date_format)); $this->assertNoRaw($end_date->format($time_format)); - // Verify the date doesn't change if using a timezone that is UTC+12 when - // the entity is edited through the form. + // Verify the date doesn't change when entity is edited through the form. $entity = EntityTest::load($id); $this->assertEqual('2012-12-31', $entity->{$field_name}->value); $this->assertEqual('2013-06-06', $entity->{$field_name}->value2);