Problem/Motivation

In #2993165: Date Only field shows incorrect default value when UTC date is different than user's date we discovered that the documentation on \Drupal\Component\Datetime\DateTimePlus::setDefaultDateTime() should be improved.

This task was created to do this.

I think we should reconsider the documentation of \Drupal\Component\Datetime\DateTimePlus::setDefaultDateTime() - on its own this method leads to this problem. It's called from a few places in core but this is the only place where the timezone on the date might not be UTC. The other runtime place is \Drupal\datetime\DateTimeComputed::getValue() - fwiw I'm not sure if implementation is correct. Dates and timezone stuff is hard to reason about. But this should be in a follow-up to improve the docs on setDefaultDateTime

Thus spoketh @alexpott in #2993165-58: Date Only field shows incorrect default value when UTC date is different than user's date

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Spokje created an issue. See original summary.

alexpott’s picture

I'm not sure how to fix the docs here - it is really complex but I think this method is very easy to use wrongly.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.