Review 12.4 Merged

83682[BUGFIX] Use correct timezones with timestamp based \DateTime

Stefan Bürk CR +2 V +2 Normal +85 −71 updated 04/07/24, 09:49

Commit message

As documented by PHP, `\DateTime` or `\DateTimeImmutable`
objects created with a timestamp only ('@12345678') as the
first constructor argument will use UTC as TimeZone.

Creating an object instance without any constructor arguments
will use the `date_default_timezone_get()` timezone for the
object - and setting the timestamp using `setTimestamp()` will
not change the object's timezone.

That means, that formatting the value will be done using
the object Timezone and **NOT** the default PHP Timezone
(`date_default_timezone_get()`).

Consequently, this may lead to wrong interpretation of
the displayed formatted value in the context of another
timezone - if no timezone information (+0000/-0100) is
included.

This change streamlines this for a couple of places were
it is expected to format date, datetime or time values
for the current context timezone by ensuring objects get
the current timezone set instead of `UTC`.

Note: Changing the date default timezone on the fly after
an object has been created will show a similar effect like
using constructor values, even if the object has been
created by using the `setTimestamp()` method.

[1] https://3v4l.org/sGEe2

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
  • Verified V +2 Done
    • Stefan Bürk +2
    • core-ci +1 CI

Issues 2

Files 20

Review log 34

  1. Stefan Bürk uploaded patch set 1 04/07/24, 08:27

  2. core-ci voted on patch set 1 V +1 04/07/24, 08:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55494

  3. Stefan Bürk voted on patch set 1 CR +2 V +2 04/07/24, 09:49

  4. Stefan Bürk merged patch set 2 04/07/24, 09:49