Project

General

Profile

Actions

Bug #91838

closed

TCA l10n_mode="exclude" with TCA config dbType='datetime' set wrong timezone in translated records

Added by Devid Messner over 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2020-07-22
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

For TCA fields of the type "datetime" where "l10n_mode=exclude" is set, the DB field (which is already in UTC format) is converted to UTC again when the translated data records are synchronized with the original data record. The reason is that the time zone information is missing in the database.

Example:

TCA Configuration:

'date' => [
    'exclude' => true,
    'label' => 'date',
    'config' => [
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'dbType' => 'datetime',
        'eval' => 'datetime,required'
    ],
    'l10n_mode' => 'exclude',
],

Mysql Field
    date datetime,

LocalConfiguration:
'SYS' => [    
    'phpTimeZone' => 'Europe/Berlin',
    'serverTimeZone' => 'Europe/Berlin',  
],

If I save the field with the value " 14:00 03-09-2020" then this date is sent in the format "2020-09-03T*14:00*:00Z" (I think the time zone is already set correctly in the frontend) and stored in the database with the date "2020-09-03 14:00 :00". The correct date will also be saved correctly in the translated data set.

But when I edit and save the translated dataset, the date of the original dataset "2020-09-03 14:00:00" is copied from the database (without time zone). The datahandler converts the date into UTC format and the new "wrong" date "2020-09-03 12:00:00" is written back to the database.

I think it's the same problem as issue #81228

The following patch has worked for me

--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -1966,7 +1966,7 @@ protected function checkValueForInput($value, $tcaFieldConf, $table, $id, $realP
                 // Convert the date/time into a timestamp for the sake of the checks
                 $emptyValue = $dateTimeFormats[$tcaFieldConf['dbType']]['empty'];
                 // We store UTC timestamps in the database, which is what getTimestamp() returns.
-                $dateTime = new \DateTime($value);
+                $dateTime = new \DateTime($value, new \DateTimeZone('UTC'));
                 $value = $value === $emptyValue ? null : $dateTime->getTimestamp();
             }
         }


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #89914: Native date (TCA dbType) fields are not properly copied or localizedClosed2019-12-11

Actions
Related to TYPO3 Core - Bug #79249: TCA fields with eval types "time" or "timesec" are incorrectly stored in the databaseClosedMarkus Klein2017-01-10

Actions
Actions #1

Updated by Imko Schumacher almost 4 years ago

  • Related to Bug #89914: Native date (TCA dbType) fields are not properly copied or localized added
Actions #2

Updated by Benni Mack over 1 year ago

  • Related to Bug #79249: TCA fields with eval types "time" or "timesec" are incorrectly stored in the database added
Actions #3

Updated by Benni Mack over 1 year ago

  • Status changed from New to Closed

I do think this is fixed now, since TYPO3 now uses the exact code snippet in a few versions.

If you feel this is still an issue in v12+, let me know and i will re-open the ticket.

Actions

Also available in: Atom PDF