From d51dd25afffc1fd7e6f27c7b346477733502f23c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 31 Mar 2014 13:06:50 +0200 Subject: [PATCH] Added ability to negate browser timezone in datetimepicker 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index c50c51dbb1..fb1a4a7828 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -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', -- 2.20.1