Project

General

Profile

Actions

Bug #80349

open

Epic #77562: Misbehaviors with datetime values and timezones

Extbase mapping of \DateTime for integer values does not set timezone with region string but only offset

Added by Andreas Allacher about 7 years ago. Updated almost 5 years ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Extbase
Start date:
2017-03-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Currently the extbase DataMapper handles the conversion of integer values to \DateTime
in https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php#l315
like this:
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($targetType, date('c', $value));

Therefore the value itself will be correct but the timezone will be e.g. "+01:00" or similar instead of e.g. "Europe/Vienna".

That means it will be fine as long as one doesn't modify the date.
For instance, a date like March 20th 00:00:00 with \DateTimeZone "+01:00" when calling $date->modify('+1 month')
if one were to use "Europe/Vienna" the date would switch to daylight savings time.
How the result with the \DateTimeZone "+01:00" then the result will be April 20th 00:00:00 with \DateTimeZone "+01:00" which means the \DateTimeZone is wrong as with daylight savings time it would actually be "+02:00".

This means a comparison of a date in the correct timezone to the calculated one might fail or be of by the difference between daylight saving time and normal time.

However, if the \DateTimeZone is the regional \DateTimeZone like e.g. "Europe/Vienna" this will work correctly.

The easiest solution is probably to add $date->setTimezone prior to return the \DateTime.


Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Feature #80559: datetime and time handling should always have timezone informationClosed2017-03-29

Actions
Related to TYPO3 Core - Bug #68651: Datetime() properties have wrong timezoneAcceptedAndreas Wolf2015-07-30

Actions
Actions

Also available in: Atom PDF