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 over 7 years ago. Updated over 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 3 (2 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
Related to TYPO3 Core - Bug #79557: Date fields DataMapper handling problemNew2017-01-30

Actions
Actions #1

Updated by Mona Muzaffar over 7 years ago

  • Related to Epic #80852: Datetime handling in backend added
Actions #2

Updated by Benni Mack over 7 years ago

  • Target version changed from 8 LTS to next-patchlevel
Actions #3

Updated by Gerrit Code Review over 7 years ago

  • Status changed from New to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52952

Actions #4

Updated by Paul Golmann over 7 years ago

I found myself with the same problem. I've created a patch (see below for explanation).

The problem is, as far as I can see:

date('c', $value)
creates a string representing the date/datetime including the timezone, which is what we want. But the string representation (ISO 8601) encodes the timezone as a offset (e.g. 2017-10-20T00:00:00+02:00 if the local server time (SYS['phpTimeZone']) is set to Berlin/Europe). That leads the resulting \DateTime to only have the offset but not the timezone region. That means when "working" on the DateTime information about e.g. the summer time/daytime saving gets lost. For me that caused shifting of dates around the (german) summer time change in October this year using a calendarize configuration with a frequency.

In the patch I've aligned the code for mapping timestamps with that of datetime database fields. That means that the timezone will correctly be set as Europe/Berlin instead of +02:00.

Greetings. Paul

Actions #5

Updated by Gerrit Code Review over 7 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52952

Actions #6

Updated by Paul Golmann over 7 years ago

  • Related to Bug #68651: Datetime() properties have wrong timezone added
Actions #7

Updated by Paul Golmann over 7 years ago

  • Related to Bug #68651: Datetime() properties have wrong timezone added
Actions #8

Updated by Paul Golmann over 7 years ago

  • Related to deleted (Bug #68651: Datetime() properties have wrong timezone)
Actions #9

Updated by Gerrit Code Review over 7 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52952

Actions #10

Updated by Markus Klein over 7 years ago

  • Parent task set to #77562
Actions #11

Updated by Riccardo De Contardi over 7 years ago

  • Related to deleted (Epic #80852: Datetime handling in backend)
Actions #12

Updated by Gerrit Code Review almost 7 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52952

Actions #13

Updated by Benni Mack about 6 years ago

  • Status changed from Under Review to New
Actions #14

Updated by Benni Mack over 5 years ago

  • Target version changed from next-patchlevel to Candidate for patchlevel
Actions #15

Updated by Benni Mack 5 months ago

  • Related to Bug #79557: Date fields DataMapper handling problem added
Actions

Also available in: Atom PDF