[BUGFIX] Show correct timezone when displaying FormEngine time field 12/38112/15
authorAndreas Allacher <andreas.allacher@gmx.at>
Wed, 25 Mar 2015 15:40:08 +0000 (16:40 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 27 Apr 2015 17:23:26 +0000 (19:23 +0200)
"time" and "timesec" fields currently do not store time as UTC in database,
however, in the FormEngine modifications time was also handled
as being stored in UTC which results in time fields being stored and
then being modified with +/- x hours, depending on server time.
This patch reverts the behaviour back to store times as server-time.

However, in the future it would be good to store those values as UTC too,
but that will require more changes and would also be a breaking change.

Change-Id: I6c299bfa3d0387081f00c6cba7723e10236fabf0
Resolves: #65976
Releases: master
Reviewed-on: http://review.typo3.org/38112
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Jan Helke <typo3@helke.de>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Element/InputElement.php

index 1c7901d..fb75cc3 100644 (file)
@@ -91,8 +91,7 @@ class InputElement extends AbstractFormElement {
 
 
                if (in_array('datetime', $evalList, TRUE)
-                       || in_array('date', $evalList)
-                       || in_array('time', $evalList)) {
+                       || in_array('date', $evalList)) {
 
                        $classes[] = 't3js-datetimepicker';
                        $isDateField = TRUE;
@@ -102,9 +101,6 @@ class InputElement extends AbstractFormElement {
                        } elseif (in_array('date', $evalList)) {
                                $attributes['data-date-type'] = 'date';
                                $dateFormat = $dateFormats['date'];
-                       } else {
-                               $attributes['data-date-type'] = 'time';
-                               $dateFormat = $dateFormats['time'];
                        }
                        if ($additionalInformation['itemFormElValue'] > 0) {
                                $additionalInformation['itemFormElValue'] += date('Z', $additionalInformation['itemFormElValue']);
@@ -115,7 +111,14 @@ class InputElement extends AbstractFormElement {
                        if (isset($config['range']['upper'])) {
                                $attributes['data-date-maxDate'] = (int)$config['range']['upper'];
                        }
+               } elseif (in_array('time', $evalList)) {
+                       $dateFormat = $dateFormats['time'];
+                       $isDateField = TRUE;
+                       $classes[] = 't3js-datetimepicker';
+                       $attributes['data-date-type'] = 'time';
                } elseif (in_array('timesec', $evalList)) {
+                       $dateFormat = $dateFormats['timesec'];
+                       $isDateField = TRUE;
                        $classes[] = 't3js-datetimepicker';
                        $attributes['data-date-type'] = 'timesec';
                } else {
@@ -130,7 +133,7 @@ class InputElement extends AbstractFormElement {
                                case 'required':
                                        $this->formEngine->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $additionalInformation['itemFormElName']);
                                        // Mark this field for date/time disposal:
-                                       if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
+                                       if (array_intersect($evalList, array('date', 'datetime', 'time', 'timesec'))) {
                                                $this->formEngine->requiredAdditional[$additionalInformation['itemFormElName']]['isPositiveNumber'] = TRUE;
                                        }
                                        break;