From 086b153ae274e528e709d179795d0bafd5f382bd Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 31 Oct 2012 11:50:33 +0100 Subject: Improve client-side timezone detection using jsTimezoneDetect by Jon Nylander (#1488725); removed obsolete dstactive detection --- program/js/app.js | 14 ++++++++------ program/js/jstz.min.js | 11 +++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 program/js/jstz.min.js (limited to 'program/js') diff --git a/program/js/app.js b/program/js/app.js index c151a1012..6741a480e 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -424,12 +424,14 @@ function rcube_webmail() $('#rcmloginpwd').focus(); // detect client timezone - var dt = new Date(), - tz = dt.getTimezoneOffset() / -60, - stdtz = dt.getStdTimezoneOffset() / -60; - - $('#rcmlogintz').val(stdtz); - $('#rcmlogindst').val(tz > stdtz ? 1 : 0); + if (window.jstz && !bw.ie6) { + var timezone = jstz.determine(); + if (timezone.name()) + $('#rcmlogintz').val(timezone.name()); + } + else { + $('#rcmlogintz').val(new Date().getStdTimezoneOffset() / -60); + } // display 'loading' message on form submit, lock submit button $('form').submit(function () { diff --git a/program/js/jstz.min.js b/program/js/jstz.min.js new file mode 100644 index 000000000..81c5057fd --- /dev/null +++ b/program/js/jstz.min.js @@ -0,0 +1,11 @@ +var jstz=function(){var b=function(a){a=-a.getTimezoneOffset();return null!==a?a:0},c=function(){return b(new Date(2010,0,1,0,0,0,0))},f=function(){return b(new Date(2010,5,1,0,0,0,0))},e=function(){var a=c(),d=f(),b=c()-f();return new jstz.TimeZone(jstz.olson.timezones[0>b?a+",1":0