From d021fbcab62d3803f8dfff0e7351005f286cb7b0 Mon Sep 17 00:00:00 2001
From: Gabe Troyan <gabe+typo3org@ecopixel.com>
Date: Wed, 3 Nov 2021 09:24:53 -0400
Subject: [PATCH] [BUGFIX] Input and save date properly when USdateFormat is
 set

Currently, the value of `USdateFormat` is disregarded because the
corresponding property, `FormEngineValidation.USmode`, is set to zero
regardless in `FormEngineValidation.initialize()`. This change will ensure
that `USmode` will remain 1 without conflicting with core functionality
that relies on `USmode` being set *before* `initialize()` is called.

Resolves: #86679
Releases: master, 10.4
Related-to: #91105
Change-Id: I5584ca7fe92742e28147f9883fedf53e0556f1b1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72034
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../backend/Resources/Public/JavaScript/FormEngineValidation.js | 1 -
 .../sysext/backend/Tests/JavaScript/FormEngineValidationTest.js | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
index 76b911bcd01e..10b842d41553 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
@@ -66,7 +66,6 @@ define([
     FormEngineValidation.lastYear = FormEngineValidation.getYear(today);
     FormEngineValidation.lastDate = FormEngineValidation.getDate(today);
     FormEngineValidation.lastTime = 0;
-    FormEngineValidation.USmode = 0;
     FormEngineValidation.validate();
   };
 
diff --git a/typo3/sysext/backend/Tests/JavaScript/FormEngineValidationTest.js b/typo3/sysext/backend/Tests/JavaScript/FormEngineValidationTest.js
index aa925317e77b..97731bebbb93 100644
--- a/typo3/sysext/backend/Tests/JavaScript/FormEngineValidationTest.js
+++ b/typo3/sysext/backend/Tests/JavaScript/FormEngineValidationTest.js
@@ -93,6 +93,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngineValidation'], function($, FormEng
       using(formatValueDataProvider, function(testCase) {
         it(testCase.description, function() {
           FormEngineValidation.USmode = 0;
+          FormEngineValidation.initialize();
           var result = FormEngineValidation.formatValue(testCase.type, testCase.value, testCase.config);
           expect(result).toBe(testCase.result);
         });
@@ -155,6 +156,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngineValidation'], function($, FormEng
       using(formatValueUsModeDataProvider, function(testCase) {
         it(testCase.description, function() {
           FormEngineValidation.USmode = 1;
+          FormEngineValidation.initialize();
           var result = FormEngineValidation.formatValue(testCase.type, testCase.value, testCase.config);
           expect(result).toBe(testCase.result);
         });
-- 
GitLab