Skip to content

Commit

Permalink
[TASK] Use ISO 8601 format for date rendering
Browse files Browse the repository at this point in the history
Resolves: #103496
Releases: main, 12.4
Change-Id: I688540c91e85d28eec1951305d63028efa27eb82
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83653
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
mbrodala authored and bmack committed Apr 3, 2024
1 parent 56e8436 commit 9e94d70
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 22 deletions.
Expand Up @@ -68,7 +68,7 @@ public function downloadReturnsAListOfAllBackendUsers(): void
'email' => '',
'realName' => '',
'admin' => 'Yes',
'crdate' => '22-04-13 14:55',
'crdate' => '2013-04-22 14:55',
],
], $this->prepareRecordsForDbCompatAssertions($result));
}
Expand Down
Expand Up @@ -80,7 +80,7 @@ public function flattenResultDataValueFlattensFile(): void
self::assertSame(
[
'id' => 'foo',
'date' => '29-11-73',
'date' => '1973-11-29',
'icon' => '',
'thumbUrl' => '',
'path' => '',
Expand Down
Expand Up @@ -82,7 +82,7 @@ public static function formatValueDataProvider(): array
'format' => 'datetime',
],
'1412358894',
'03-10-14 17:54',
'2014-10-03 17:54',
],
'format to datetime with empty value' => [
[
Expand Down
Expand Up @@ -265,7 +265,7 @@ public static function addDataReturnsRecordTitleForDatetimeTypeDataProvider(): a
'format' => 'date',
],
'978307261',
'01-01-01 (-7 days)',
'2001-01-01 (-7 days)',
],
'date (dbType: date)' => [
[
Expand All @@ -274,7 +274,7 @@ public static function addDataReturnsRecordTitleForDatetimeTypeDataProvider(): a
'dbType' => 'date',
],
'2001-01-01',
'01-01-01 (-7 days)',
'2001-01-01 (-7 days)',
],
'date (disableAgeDisplay: TRUE)' => [
[
Expand All @@ -283,7 +283,7 @@ public static function addDataReturnsRecordTitleForDatetimeTypeDataProvider(): a
'disableAgeDisplay' => true,
],
'978307261',
'01-01-01',
'2001-01-01',
],
'time' => [
[
Expand Down Expand Up @@ -325,15 +325,15 @@ public static function addDataReturnsRecordTitleForDatetimeTypeDataProvider(): a
'dbType' => 'date',
],
'978307261',
'01-01-01 00:01',
'2001-01-01 00:01',
],
'datetime (dbType: datetime)' => [
[
'type' => 'datetime',
'dbType' => 'datetime',
],
'2014-12-31 23:59:59',
'31-12-14 23:59',
'2014-12-31 23:59',
],
];
}
Expand Down
14 changes: 7 additions & 7 deletions typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php
Expand Up @@ -562,27 +562,27 @@ public function getProcessedValueDisplaysAgeForDateInputFieldsIfSettingAbsent():
],
],
];
self::assertSame('28-08-15 (-2 days)', BackendUtility::getProcessedValue('tt_content', 'date', mktime(0, 0, 0, 8, 28, 2015)));
self::assertSame('2015-08-28 (-2 days)', BackendUtility::getProcessedValue('tt_content', 'date', mktime(0, 0, 0, 8, 28, 2015)));
}

public static function inputTypeDateDisplayOptions(): array
{
return [
'typeSafe Setting' => [
true,
'28-08-15',
'2015-08-28',
],
'non typesafe setting' => [
1,
'28-08-15',
'2015-08-28',
],
'setting disabled typesafe' => [
false,
'28-08-15 (-2 days)',
'2015-08-28 (-2 days)',
],
'setting disabled not typesafe' => [
0,
'28-08-15 (-2 days)',
'2015-08-28 (-2 days)',
],
];
}
Expand Down Expand Up @@ -1123,8 +1123,8 @@ public function dateTimeAgeReturnsCorrectValues(): void
$GLOBALS['LANG'] = $languageServiceMock;
$GLOBALS['EXEC_TIME'] = mktime(0, 0, 0, 3, 23, 2016);

self::assertSame('24-03-16 00:00 (-1 day)', BackendUtility::dateTimeAge($GLOBALS['EXEC_TIME'] + 86400));
self::assertSame('24-03-16 (-1 day)', BackendUtility::dateTimeAge($GLOBALS['EXEC_TIME'] + 86400, 1, 'date'));
self::assertSame('2016-03-24 00:00 (-1 day)', BackendUtility::dateTimeAge($GLOBALS['EXEC_TIME'] + 86400));
self::assertSame('2016-03-24 (-1 day)', BackendUtility::dateTimeAge($GLOBALS['EXEC_TIME'] + 86400, 1, 'date'));
}

#[Test]
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Configuration/DefaultConfiguration.php
Expand Up @@ -84,7 +84,7 @@
'cookieDomain' => '',
'trustedHostsPattern' => 'SERVER_NAME',
'devIPmask' => '127.0.0.1,::1',
'ddmmyy' => 'd-m-y',
'ddmmyy' => 'Y-m-d',
'hhmm' => 'H:i',
'loginCopyrightWarrantyProvider' => '',
'loginCopyrightWarrantyURL' => '',
Expand Down
Expand Up @@ -87,10 +87,10 @@ SYS:
description: 'Defines a list of IP addresses which will allow development-output to display. The debug() function will use this as a filter. See the function <code>\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP()</code> for details on syntax. Setting this to blank value will deny all. Setting to "*" will allow all.'
ddmmyy:
type: text
description: 'Format of Day-Month-Year - see PHP-function <a href="https://php.net/date" target="_blank" rel="noreferrer">date()</a>'
description: 'Format of dates (without times) - see PHP-function <a href="https://php.net/date" target="_blank" rel="noreferrer">date()</a>'
hhmm:
type: text
description: 'Format of Hours-Minutes - see PHP-function <a href="https://php.net/date" target="_blank" rel="noreferrer">date()</a>'
description: 'Format of times (without dates) - see PHP-function <a href="https://php.net/date" target="_blank" rel="noreferrer">date()</a>'
defaultScheme:
type: text
allowedValues:
Expand Down
@@ -0,0 +1,25 @@
.. include:: /Includes.rst.txt

.. _important-103496-1711623416:

=======================================================
Important: #103496 - ISO format used for date rendering
=======================================================

See :issue:`103496`

Description
===========

The default format for date rendering configured in :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']` has changed.

The former arbitrary :php:`'d-m-y'` format was replaced with the standard ISO 8601 :php:`'Y-m-d'` format.

Examples of dates where the :php:`'d-m-y'` format led to unclear dates:

* A 2-digit year could also be a day in a month: `21-04-23` could be understood as `2021-04-23` instead of `2023-04-21`.
* The century of years could not be distinguished: `21-04-71` could be `2071-04-21` or `1971-04-21`

This affects date display in various locations so code relying on the previous format (e.g. acceptance tests) must be updated accordingly.

.. index:: Backend, CLI, Frontend, TCA, ext:core
Expand Up @@ -230,8 +230,8 @@ public function editViewTest(): void

self::assertMatchesRegularExpression('/<td>.*Name.*<td>.*some name/s', $response);
self::assertMatchesRegularExpression('/<td>.*Recovery codes left.*<td>.*2/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last updated.*<td>.*18-03-21/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last used.*<td>.*18-03-21/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last updated.*<td>.*2021-03-18/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last used.*<td>.*2021-03-18/s', $response);
self::assertMatchesRegularExpression('/<input.*id="regenerateCodes"/s', $response);
}

Expand Down
Expand Up @@ -241,8 +241,8 @@ public function editViewTest(): void
$response = $this->subject->handleRequest($request, $propertyManager, MfaViewType::EDIT)->getBody()->getContents();

self::assertMatchesRegularExpression('/<td>.*Name.*<td>.*some name/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last updated.*<td>.*18-03-21/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last used.*<td>.*18-03-21/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last updated.*<td>.*2021-03-18/s', $response);
self::assertMatchesRegularExpression('/<td>.*Last used.*<td>.*2021-03-18/s', $response);
}

#[Test]
Expand Down

0 comments on commit 9e94d70

Please sign in to comment.