Problem/Motivation
DateTimeWidgetBase sets timezone twice to the same value/creates unnecessary objects/minor bloat.
...
if ($items[$delta]->date) {
$date = $items[$delta]->date;
// The date was created and verified during field_load(), so it is safe to
// use without further inspection.
$date->setTimezone(new \DateTimeZone($element['value']['#date_timezone']));
$element['value']['#default_value'] = $this->createDefaultValue($date, $element['value']['#date_timezone']);
}
...
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->setDefaultDateTime();
}
$date->setTimezone(new \DateTimeZone($timezone));
return $date;
}
Proposed resolution
Clean up duplication
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
None
Issue fork drupal-3251100
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
nickdickinsonwildeComment #4
larowlanLooks reasonable to me (disclaimer reviewed this on my phone)
This sort of cleanup is normally a task rather than a bug
Comment #6
alexpottCommitted and pushed 4e34cd3fd0a to 10.0.x and bbc518ad835 to 9.4.x. Thanks!