Actions
Bug #98045
closedDateAspect->getTimezone (almost) never returns the correct value
Start date:
2022-07-28
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
On the way the DateTimeAspect is initiated, there is never an evaluation of the current time zone. Thus the aspect always returns only the time zone "+00:00". Also the ISO date is always given in UTC instead of the currently set server time zone.
An example of this is given in the method TYPO3\CMS\Frontend\Http\Application::initializeContext():
$this->context->setAspect('date', new DateTimeAspect(new \DateTimeImmutable('@' . $GLOBALS['EXEC_TIME'])));
A proof-of-concept code that makes the aspect return the correct values:
$dateTime = new \DateTime('@' . $GLOBALS['EXEC_TIME']);
$dateTime->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$this->context->setAspect('date', new DateTimeAspect(\DateTimeImmutable::createFromMutable($dateTime)));
This aspect is created in several places in the TYPO3 core. The value of date_default_timezone_get()
is already defined beforehand by TYPO3 (if required) and should thus be able to be taken.
Apparently this bug has been present since the existence of the aspects until the current branch of the 12 version.
Actions