From: Alexander Ebert Date: Mon, 31 Mar 2014 11:06:50 +0000 (+0200) Subject: Added ability to negate browser timezone in datetimepicker X-Git-Tag: 2.0.5~14^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d51dd25afffc1fd7e6f27c7b346477733502f23c;p=GitHub%2FWoltLab%2FWCF.git 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) --- 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',