diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index 1078541..103a8bb 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -50,6 +50,9 @@ function datetime_help($route_name, RouteMatchInterface $route_match) { * same value for in both the local timezone and UTC. * * @param $date + * + * @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. Use + * (TBD) instead. */ function datetime_date_default_time($date) { $date->setTime(12, 0, 0); diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php index 678ddc8..a2ef7d5 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php @@ -40,10 +40,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) { /** @var \Drupal\Core\Datetime\DrupalDateTime $date */ $date = $item->date; - if ($this->getFieldSetting('datetime_type') == 'date') { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } $this->setTimeZone($date); $output = $this->formatDate($date); diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php index 03c92ae..e0fe538 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -42,11 +42,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) { /** @var \Drupal\Core\Datetime\DrupalDateTime $date */ $date = $item->date; - if ($this->getFieldSetting('datetime_type') == 'date') { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } - // Create the ISO date in Universal Time. $iso_date = $date->format("Y-m-d\TH:i:s") . 'Z'; diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php index 683d75c..a8ff469 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php @@ -30,10 +30,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) { /** @var \Drupal\Core\Datetime\DrupalDateTime $date */ $date = $item->date; - if ($this->getFieldSetting('datetime_type') == 'date') { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } $this->setTimeZone($date); $output = $this->formatDate($date); diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php index 859ea5d..e79a94a 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php @@ -110,10 +110,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $date = $item->date; $output = []; if (!empty($item->date)) { - if ($this->getFieldSetting('datetime_type') == 'date') { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } $output = $this->formatDate($date); } $elements[$delta] = $output; diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php index aa6175a..c36f87f 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php @@ -44,11 +44,6 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $date = $items[$delta]->date; // 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) { - // A date without time will pick up the current time, use the default - // time. - datetime_date_default_time($date); - } $date->setTimezone(new \DateTimeZone($element['value']['#date_timezone'])); $element['value']['#default_value'] = $date; } @@ -68,9 +63,6 @@ public function massageFormValues(array $values, array $form, FormStateInterface $date = $item['value']; switch ($this->getFieldSetting('datetime_type')) { case DateTimeItem::DATETIME_TYPE_DATE: - // If this is a date-only field, set it to the default time so the - // timezone conversion can be reversed. - datetime_date_default_time($date); $format = DATETIME_DATE_STORAGE_FORMAT; break; diff --git a/core/modules/datetime_range/src/DateTimeRangeTrait.php b/core/modules/datetime_range/src/DateTimeRangeTrait.php index 5a34f2c..69df5cc 100644 --- a/core/modules/datetime_range/src/DateTimeRangeTrait.php +++ b/core/modules/datetime_range/src/DateTimeRangeTrait.php @@ -20,10 +20,6 @@ * A render array. */ protected function buildDate(DrupalDateTime $date) { - if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } $this->setTimeZone($date); $build = [ @@ -48,11 +44,6 @@ protected function buildDate(DrupalDateTime $date) { * A render array. */ protected function buildDateWithIsoAttribute(DrupalDateTime $date) { - if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } - // Create the ISO date in Universal Time. $iso_date = $date->format("Y-m-d\TH:i:s") . 'Z'; diff --git a/core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeWidgetBase.php b/core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeWidgetBase.php index 87cecbb..30f58af 100644 --- a/core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeWidgetBase.php +++ b/core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeWidgetBase.php @@ -54,9 +54,6 @@ public function massageFormValues(array $values, array $form, FormStateInterface $start_date = $item['value']; switch ($this->getFieldSetting('datetime_type')) { case DateRangeItem::DATETIME_TYPE_DATE: - // If this is a date-only field, set it to the default time so the - // timezone conversion can be reversed. - datetime_date_default_time($start_date); $format = DATETIME_DATE_STORAGE_FORMAT; break; @@ -84,9 +81,6 @@ public function massageFormValues(array $values, array $form, FormStateInterface $end_date = $item['end_value']; switch ($this->getFieldSetting('datetime_type')) { case DateRangeItem::DATETIME_TYPE_DATE: - // If this is a date-only field, set it to the default time so the - // timezone conversion can be reversed. - datetime_date_default_time($end_date); $format = DATETIME_DATE_STORAGE_FORMAT; break; @@ -155,11 +149,6 @@ public function validateStartEnd(array &$element, FormStateInterface $form_state 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) { - // A date without time will pick up the current time, use the default - // time. - datetime_date_default_time($date); - } $date->setTimezone(new \DateTimeZone($timezone)); return $date; }