[BUGFIX] Fix date generation in AdminPanel preview 47/59047/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 6 Dec 2018 15:24:28 +0000 (16:24 +0100)
committerMathias Brodala <mbrodala@pagemachine.de>
Thu, 6 Dec 2018 15:50:03 +0000 (16:50 +0100)
This patch fixes multiple issues when generating a date in AdminPanel's
preview module:

- The order of the date segements is changed to have a valid ISO format
- Months are 0-based in JavaScript (0 = January, 11 = December), for this
  reason, +1 is added to have a valid date string

Resolves: #87060
Releases: master
Change-Id: Ib6a86e65b962a21eb9c033801a8711cb4f12f193
Reviewed-on: https://review.typo3.org/59047
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
typo3/sysext/adminpanel/Resources/Public/JavaScript/Modules/Preview.js

index 4add742..4960176 100644 (file)
@@ -14,7 +14,7 @@ function initializePreviewModule() {
                var timeVal = document.getElementById('preview_simulateDate-time-hr').value;
                if (!dateVal && timeVal) {
                        var tempDate = new Date();
-                       dateVal = tempDate.getDate() + "-" + tempDate.getMonth() + "-" + tempDate.getFullYear();
+                       dateVal = tempDate.getFullYear() + "-" + (tempDate.getMonth() + 1) + "-" + tempDate.getDate();
                }
                if (dateVal && !timeVal) {
                        timeVal =  "00:00";