Project

General

Profile

Actions

Bug #91508

closed

Epic #77562: Misbehaviors with datetime values and timezones

It is not possible to save "negative" dates, e.g. a year before jesus christus with date inputs

Added by Daniel Siepmann over 4 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2020-05-27
Due date:
% Done:

0%

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

Description

Example setup to reproduce:

1. raise storage for field:

CREATE TABLE tt_content (
    starttime bigint,
);

2. Select an date before year 0.
3. Save
4. You'll see the same year but after 0, not before 0.

The same happens when changing the setup of the field:


$GLOBALS['TCA']['tt_content']['columns']['starttime'] = [
    'exclude' => 0,
    'label' => 'Some year',
    'config' => [
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'eval' => 'date, int, required',
    ],
];


Files

Screenshot from 2020-05-27 16-26-19.png (9.15 KB) Screenshot from 2020-05-27 16-26-19.png After selecting date, before saving Daniel Siepmann, 2020-05-27 16:26
Screenshot from 2020-05-27 16-26-29.png (9.09 KB) Screenshot from 2020-05-27 16-26-29.png After saving Daniel Siepmann, 2020-05-27 16:26
Screenshot from 2020-06-03 08-51-38.png (10.7 KB) Screenshot from 2020-06-03 08-51-38.png JS Console formatting moment js Daniel Siepmann, 2020-06-03 08:51

Related issues 4 (0 open4 closed)

Related to TYPO3 Core - Bug #79448: Handling dates in the very past inside T3-BackendClosed2017-01-24

Actions
Related to TYPO3 Core - Bug #37244: TCA date evaluation for dates lower 01-01-1970 failsClosed2012-05-17

Actions
Related to TYPO3 Core - Bug #104192: Not possible to change date format to US format anymoreClosed2024-06-20

Actions
Related to TYPO3 Core - Task #104309: Use ISO dates in FormEngine date handlingClosed2024-07-04

Actions
Actions #1

Updated by Daniel Siepmann over 4 years ago

Digging deeper, I found out that TYPO3/CMS/Backend/FormEngineValidation is converting the year into positive year already inside FormEngineValidation.updateInputField.

When faking and overwriting the values in this method, moment js will still format the year as positive year.

Actions #2

Updated by Riccardo De Contardi over 4 years ago

  • Parent task set to #77562
Actions #3

Updated by Riccardo De Contardi over 4 years ago

Maybe related? #79448

Actions #4

Updated by Daniel Siepmann about 4 years ago

  • Related to Bug #79448: Handling dates in the very past inside T3-Backend added
Actions #5

Updated by Quadronet no-lastname-given about 3 years ago

is there any solution for TYPO3 10?
It will be use in timeline extensions.

Actions #6

Updated by Benni Mack over 1 year ago

  • Status changed from New to Closed

we've finally fixed this in TYPO3 v12. With type=datetime (and even better with dbType=date and format=date) this works just fine, tested this just now. https://docs.typo3.org/m/typo3/reference-tca/12.4/en-us/ColumnsConfig/Type/Datetime/Index.html

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

Actions #7

Updated by Daniel Siepmann 10 months ago ยท Edited

  • Status changed from Closed to New

I currently can't make this work in v12.
MySQL already states it can't handle dates prior year 1000: https://dev.mysql.com/doc/refman/8.0/en/datetime.html

The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.

Also the JS doesn't allow me to select older dates. It works fine until 1970, but older dates behave strange. E.g. I could insert Year 100, but counting down ends up in 1999. Negative years are even ignored within the date picker.

Tested with v12.4.10.

I used the following TCA (with auto generated sql):

        'date' => [
            'exclude' => 0,
            'label' => $languageFile . '.date',
            'config' => [
                'type' => 'datetime',
                'format' => 'date',
                'dbType' => 'date',
                'required' => true,
            ],
        ],
Actions #8

Updated by Daniel Siepmann 10 months ago

  • Related to Bug #37244: TCA date evaluation for dates lower 01-01-1970 fails added
Actions #9

Updated by Garvin Hicking 5 months ago

  • Related to Bug #104192: Not possible to change date format to US format anymore added
  • Related to Task #104309: Use ISO dates in FormEngine date handling added
Actions #10

Updated by Garvin Hicking 5 months ago

  • Status changed from New to Closed

I am closing this bug; the datepicker in v12 and v13 does work with dates down to "1000". For this to work though it is vital that the date TCA is either set to format=date (and using bigint signed as type), or format=Date+dbType=date (using native "date") field. In both cases entering a date like "02-06-1030" works here.

Theoretically the flatpickr (JS datepicker) should be able to also pick dates before "1000". However I believe because TYPO3 formats the date as "d-m-Y" (actually, dd-MM-yyyy) instead of "Y-m-d" there is some kind of mismatch here. The flatpickr demo itself can actually handle dates lower than 1000, but in TYPO3 context the cut-off seems to be "1000". Probably because "yyyy" no longer matches "yyy" (3 digits).

I would like to close this issue in favor of #104309 because I know Andreas is currently knee-deep in this; and if this is salvageable, I'm hoping this is where it gets addressed for.

If you believe closing this issue is a wronhg decision, please let me know.

Actions #11

Updated by Garvin Hicking 5 months ago

(Addendum: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84902 does indeed fix this and allows to pick years with less than 4 digits ("0999", "0001").

Actions

Also available in: Atom PDF