From 65082b3adbfaa04c4aff7c41147bb43e34941106 Mon Sep 17 00:00:00 2001 From: thomascube Date: Wed, 28 Sep 2011 11:49:37 +0000 Subject: Distinguish standard timezone offset and DST of client --- program/js/app.js | 5 ++++- program/js/common.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'program/js') diff --git a/program/js/app.js b/program/js/app.js index 22599ebf0..1a8d96793 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -380,7 +380,10 @@ function rcube_webmail() $('#rcmloginpwd').focus(); // detect client timezone - $('#rcmlogintz').val(new Date().getTimezoneOffset() / -60); + var tz = new Date().getTimezoneOffset() / -60; + var stdtz = new Date().getStdTimezoneOffset() / -60; + $('#rcmlogintz').val(stdtz); + $('#rcmlogindst').val(tz > stdtz ? 0 : 0); // display 'loading' message on form submit, lock submit button $('form').submit(function () { diff --git a/program/js/common.js b/program/js/common.js index f69125bcc..831e44a21 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -671,6 +671,23 @@ RegExp.escape = function(str) return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); }; +// Extend Date prototype to detect Standard timezone without DST +// from http://www.michaelapproved.com/articles/timezone-detect-and-ignore-daylight-saving-time-dst/ +Date.prototype.getStdTimezoneOffset = function() +{ + var m = 12, + d = new Date(null, m, 1), + tzo = d.getTimezoneOffset(); + + while (--m) { + d.setUTCMonth(m); + if (tzo != d.getTimezoneOffset()) { + return Math.max(tzo, d.getTimezoneOffset()); + } + } + + return tzo; +} // Make getElementById() case-sensitive on IE if (bw.ie) -- cgit v1.2.3