[BUGFIX] Datepicker must care about special types 40/42040/6
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 28 Jul 2015 12:40:59 +0000 (14:40 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 28 Jul 2015 19:00:36 +0000 (21:00 +0200)
Change-Id: Ia68c13f30444e76689efee7b8630a8b3fc7687f5
Resolves: #68579
Releases: master
Reviewed-on: http://review.typo3.org/42040
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Resources/Public/JavaScript/DateTimePicker.js

index d6c0e97..85ca527 100644 (file)
@@ -98,14 +98,27 @@ define('TYPO3/CMS/Backend/DateTimePicker', ['jquery'], function ($) {
                                                var format = $element.data('DateTimePicker').format();
                                                var date = moment($element.val(), format);
                                                var calculateTimeZoneOffset = $element.data('date-offset');
+                                               var timeZoneOffset;
+
                                                if (typeof calculateTimeZoneOffset !== 'undefined') {
-                                                       var timeZoneOffset = parseInt(calculateTimeZoneOffset);
+                                                       timeZoneOffset = parseInt(calculateTimeZoneOffset);
                                                } else {
-                                                       var timeZoneOffset = date.utcOffset() * 60 * -1;
+                                                       timeZoneOffset = date.utcOffset() * 60 * -1;
                                                }
 
                                                if (date.isValid()) {
-                                                       $hiddenField.val(date.unix() - timeZoneOffset);
+                                                       var value;
+                                                       switch ($element.data('dateType')) {
+                                                               case 'time':
+                                                                       value = parseInt(date.format('H')) * 3600 + parseInt(date.format('m')) * 60;
+                                                                       break;
+                                                               case 'timesec':
+                                                                       value = parseInt(date.format('H')) * 3600 + parseInt(date.format('m')) * 60 + parseInt(date.format('s'));
+                                                                       break;
+                                                               default:
+                                                                       value = date.unix() - timeZoneOffset;
+                                                       }
+                                                       $hiddenField.val(value);
                                                } else {
                                                        date = moment($hiddenField.val() + timeZoneOffset, 'X');
                                                        $element.val(date.format(format));
@@ -122,24 +135,32 @@ define('TYPO3/CMS/Backend/DateTimePicker', ['jquery'], function ($) {
                                                $hiddenField.val('');
                                        } else {
                                                var date = event.date;
+
                                                var calculateTimeZoneOffset = $element.data('date-offset');
+                                               var timeZoneOffset, value;
                                                if (typeof calculateTimeZoneOffset !== 'undefined') {
-                                                       var timeZoneOffset = parseInt(calculateTimeZoneOffset);
+                                                       timeZoneOffset = parseInt(calculateTimeZoneOffset);
                                                } else {
-                                                       var timeZoneOffset = date.utcOffset() * 60 * -1;
+                                                       timeZoneOffset = date.utcOffset() * 60 * -1;
+                                               }
+
+                                               switch ($element.data('dateType')) {
+                                                       case 'time':
+                                                               value = parseInt(date.format('H')) * 3600 + parseInt(date.format('m')) * 60;
+                                                               break;
+                                                       case 'timesec':
+                                                               value = parseInt(date.format('H')) * 3600 + parseInt(date.format('m')) * 60 + parseInt(date.format('s'));
+                                                               break;
+                                                       default:
+                                                               value = date.unix() - timeZoneOffset;
                                                }
-                                               $hiddenField.val(date.unix() - timeZoneOffset);
+                                               $hiddenField.val(value);
                                        }
                                });
                        });
                }
        };
 
-       /**
-        * initialize function
-        */
-       return function() {
-               DateTimePicker.initialize();
-               return DateTimePicker;
-       }();
+       DateTimePicker.initialize();
+       return DateTimePicker;
 });