diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index 54365a6..1ebecbc 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -15,7 +15,7 @@ /** * Defines the format that date and time should be stored in. */ -const DATETIME_DATETIME_STORAGE_FORMAT = 'Y-m-d\TH:i:s'; +const DATETIME_DATETIME_STORAGE_FORMAT = 'Y-m-d\TH:i:s+00:00'; /** * Defines the format that dates should be stored in. diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php index b4e7dc4..d9c490a 100644 --- a/core/modules/datetime/src/DateTimeComputed.php +++ b/core/modules/datetime/src/DateTimeComputed.php @@ -46,7 +46,15 @@ public function getValue($langcode = NULL) { $value = $item->{($this->definition->getSetting('date source'))}; $datetime_type = $item->getFieldDefinition()->getSetting('datetime_type'); - $storage_format = $datetime_type === DateTimeItem::DATETIME_TYPE_DATE ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT; + if ($item->getFieldDefinition()->getSetting('datetime_type') === 'date') { + $storage_format = DATETIME_DATE_STORAGE_FORMAT; + } + else { + // Strip off an explicit time from the format and replace with the + // time zone placeholder to allow the string to be parsed properly. + $storage_format = preg_replace('/\+\d\d\:\d\d$/', 'P', DATETIME_DATETIME_STORAGE_FORMAT); + } + try { $date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE); if ($date instanceof DrupalDateTime && !$date->hasErrors()) { diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php index 0891589..8ad7b82 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php @@ -226,7 +226,7 @@ protected function buildDate(DrupalDateTime $date) { */ protected function buildDateWithIsoAttribute(DrupalDateTime $date) { // Create the ISO date in Universal Time. - $iso_date = $date->format("Y-m-d\TH:i:s") . 'Z'; + $iso_date = $date->format("Y-m-d\TH:i:sP", ['timezone' => 'UTC']); $this->setTimeZone($date); diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php index 330782b..1531e74 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php @@ -69,7 +69,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) 'value' => [ 'description' => 'The date value.', 'type' => 'varchar', - 'length' => 20, + 'length' => 25, ], ], 'indexes' => [