diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index 67e7299..5aa8457 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; /** * Defines the timezone that dates should be stored in. @@ -52,9 +53,10 @@ function datetime_help($route_name, RouteMatchInterface $route_match) { * @param $date * * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use - * \Drupal\Core\Datetime\DrupalDateTime::setDefaultDateTime() instead. + * \Drupal\datetime\Plugin\Field\FieldType\DateTimeItem::setDefaultDateTime() + * instead. */ function datetime_date_default_time($date) { - @trigger_error('datetime_date_default_time() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Datetime\DrupalDateTime::setDefaultDateTime() instead.', E_USER_DEPRECATED); - $date->setTime(12, 0, 0); + @trigger_error('datetime_date_default_time() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\datetime\Plugin\Field\FieldType\DateTimeItem::setDefaultDateTime() instead.', E_USER_DEPRECATED); + DateTimeItem::setDefaultDateTime($date); } diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php index 9320baf..1b1e7b2 100644 --- a/core/modules/datetime/src/DateTimeComputed.php +++ b/core/modules/datetime/src/DateTimeComputed.php @@ -61,7 +61,7 @@ public function getValue($langcode = NULL) { // @todo Update comment and/or code per the chosen solution in // https://www.drupal.org/node/2830094 if ($datetime_type === DateTimeItem::DATETIME_TYPE_DATE) { - $this->date->setTime(12, 0, 0); + DateTimeItem::setDefaultDateTime($this->date); } } } diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php index 7514ae8..ffec307 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php @@ -87,7 +87,7 @@ protected function createDefaultValue($date, $timezone) { // The date was created and verified during field_load(), so it is safe to // use without further inspection. if ($this->getFieldSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE) { - $date->setTime(12, 0, 0); + DateTimeItem::setDefaultDateTime($date); } $date->setTimezone(new \DateTimeZone($timezone)); return $date;