Added ability to negate browser timezone in datetimepicker
authorAlexander Ebert <ebert@woltlab.com>
Mon, 31 Mar 2014 11:06:50 +0000 (13:06 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 31 Mar 2014 11:06:50 +0000 (13:06 +0200)
This is a work-around for datetimepicker which make use of an external timezone picker, therefore we must block the browser from applying it's own timezone (in case it is different from the user setting)

wcfsetup/install/files/js/WCF.js

index c50c51dbb1f30f502a7a7fac880cbd4135821120..fb1a4a7828ed851b9afd8e657c233ac76cbc0ad3 100755 (executable)
@@ -2903,6 +2903,19 @@ WCF.Date.Picker = {
                                }
                                $inputValue = $inputValue.replace(' ', 'T');
                                
+                               if ($input.data('ignoreTimezone')) {
+                                       var $timezoneOffset = new Date().getTimezoneOffset();
+                                       var $timezone = ($timezoneOffset > 0) ? '-' : '+'; // -120 equals GMT+0200
+                                       $timezoneOffset = Math.abs($timezoneOffset);
+                                       var $hours = (Math.floor($timezoneOffset / 60)).toString();
+                                       var $minutes = ($timezoneOffset % 60).toString();
+                                       $timezone += ($hours.length == 2) ? $hours : '0' + $hours;
+                                       $timezone += ':';
+                                       $timezone += ($minutes.length == 2) ? $minutes : '0' + $minutes;
+                                       
+                                       $inputValue = $inputValue.replace(/[+-][0-9]{2}:[0-9]{2}$/, $timezone);
+                               }
+                               
                                $options = $.extend($options, {
                                        altFieldTimeOnly: false,
                                        altTimeFormat: 'HH:mm',