From dd152ff9ad143d1a1c3fc037c7d2c53d2bb4057f Mon Sep 17 00:00:00 2001 From: Remdex Date: Tue, 11 Nov 2014 19:01:33 +0100 Subject: [PATCH] refix #541 --- .../defaulttheme/tpl/lhchat/getstatus.tpl.php | 27 +++++++++++++++++-- .../tpl/lhchat/part/user_timezone.tpl.php | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lhc_web/design/defaulttheme/tpl/lhchat/getstatus.tpl.php b/lhc_web/design/defaulttheme/tpl/lhchat/getstatus.tpl.php index a8160fffac..582872d3d2 100644 --- a/lhc_web/design/defaulttheme/tpl/lhchat/getstatus.tpl.php +++ b/lhc_web/design/defaulttheme/tpl/lhchat/getstatus.tpl.php @@ -524,13 +524,36 @@ }, data['check_for_operator_msg']*1000); ?> ); }, + getTzOffset : function(){ + Date.prototype.stdTimezoneOffset = function() { + var jan = new Date(this.getFullYear(), 0, 1); + var jul = new Date(this.getFullYear(), 6, 1); + return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); + } + + Date.prototype.dst = function() { + return this.getTimezoneOffset() < this.stdTimezoneOffset(); + } + + var today = new Date(); + var timeZoneOffset = 0; + + if (today.dst()) { + timeZoneOffset = today.getTimezoneOffset(); + } else { + timeZoneOffset = today.getTimezoneOffset()-60; + } + + return (timeZoneOffset/60)*-1; + }, + startNewMessageCheckSingle : function() { var vid = this.cookieDataPers.vid; lh_inst.removeById('lhc_operator_message'); var th = document.getElementsByTagName('head')[0]; var s = document.createElement('script'); var locationCurrent = encodeURIComponent(window.location.href.substring(window.location.protocol.length)); - var tzOffset = ((new Date().getTimezoneOffset())/60) * -1; + var tzOffset = this.getTzOffset(); s.setAttribute('id','lhc_operator_message'); s.setAttribute('type','text/javascript'); @@ -543,7 +566,7 @@ var th = document.getElementsByTagName('head')[0]; var s = document.createElement('script'); var locationCurrent = encodeURIComponent(window.location.href.substring(window.location.protocol.length)); - var tzOffset = ((new Date().getTimezoneOffset())/60) * -1; + var tzOffset = this.getTzOffset(); s.setAttribute('id','lhc_log_pageview'); s.setAttribute('type','text/javascript'); s.setAttribute('src','current_value?>//'+this.lang+'/chat/logpageview/(tz)/'+tzOffset+'/(vid)/'+vid+'?l='+locationCurrent+this.parseStorageArguments()+this.parseOptionsOnline()+'&dt='+encodeURIComponent(document.title)); diff --git a/lhc_web/design/defaulttheme/tpl/lhchat/part/user_timezone.tpl.php b/lhc_web/design/defaulttheme/tpl/lhchat/part/user_timezone.tpl.php index 319dc5453b..cd2ce6d29f 100644 --- a/lhc_web/design/defaulttheme/tpl/lhchat/part/user_timezone.tpl.php +++ b/lhc_web/design/defaulttheme/tpl/lhchat/part/user_timezone.tpl.php @@ -18,7 +18,7 @@ if (today.dst()) { timeZoneOffset = today.getTimezoneOffset(); } else { - timeZoneOffset = today.getTimezoneOffset()+3600; + timeZoneOffset = today.getTimezoneOffset()-60; } $('input[name=user_timezone]').val(((timeZoneOffset)/60) * -1);