Merge pull request #3061 from marcosgdf/bug-timezone-2

Corrected Timezone detection by using jstz external library
This commit is contained in:
Laurent Destailleur 2015-06-19 11:13:50 +02:00
commit d99fd37f3d
5 changed files with 15 additions and 7 deletions

View File

@ -47,6 +47,7 @@ jQuery TableDnD 0.6 GPL and MIT License Yes
jQuery Timepicker 1.1.0 GPL and MIT License Yes JS library Timepicker addon for Datepicker jQuery Timepicker 1.1.0 GPL and MIT License Yes JS library Timepicker addon for Datepicker
jQuery Tiptip 1.3 GPL and MIT License Yes JS library for tooltips jQuery Tiptip 1.3 GPL and MIT License Yes JS library for tooltips
jsGantt 1.2 BSD License Yes JS library (to build Gantt reports) jsGantt 1.2 BSD License Yes JS library (to build Gantt reports)
JsTimezoneDetect 1.0.4 MIT Licence Yes JS library to detect user timezone
For licenses compatibility informations: For licenses compatibility informations:
http://www.fsf.org/licensing/licenses/index_html http://www.fsf.org/licensing/licenses/index_html

View File

@ -25,6 +25,7 @@ For users:
- [ task #1793 ] Create new permission to restrict commercial agent margin to logged user. - [ task #1793 ] Create new permission to restrict commercial agent margin to logged user.
- Add experimental module ask supplier price to request supplier quotation. - Add experimental module ask supplier price to request supplier quotation.
- Add experimental module batch management. - Add experimental module batch management.
- Fix: Corrected user timezone detection
For translators: For translators:
- Update language files. - Update language files.

View File

@ -1,5 +1,6 @@
// Copyright (C) 2011-2014 Laurent Destailleur <eldy@users.sourceforge.net> // Copyright (C) 2011-2014 Laurent Destailleur <eldy@users.sourceforge.net>
// Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com> // Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
// Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -23,6 +24,9 @@
// //
$(document).ready(function () { $(document).ready(function () {
var timezone = jstz.determine();
// Detect and save TZ and DST // Detect and save TZ and DST
var rightNow = new Date(); var rightNow = new Date();
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
@ -40,16 +44,12 @@ $(document).ready(function () {
dst = "1"; // daylight savings time is observed dst = "1"; // daylight savings time is observed
} }
var now=new Date(); var now=new Date();
var tz=now.toTimeString().match(/\(.*\)/); // now.toTimeString may return "12:39:59 GMT+0200 (CEST)"
//alert('date=' + now + ' string=' + now.toTimeString()); //alert('date=' + now + ' string=' + now.toTimeString());
var dst_first=DisplayDstSwitchDates('first'); var dst_first=DisplayDstSwitchDates('first');
var dst_second=DisplayDstSwitchDates('second'); var dst_second=DisplayDstSwitchDates('second');
//alert(dst); //alert(dst);
$('#tz').val(std_time_offset); // returns TZ $('#tz').val(std_time_offset); // returns TZ
// tz is null with IE $('#tz_string').val(timezone.name()); // returns TZ string
if (tz != null) {
$('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string
}
$('#dst_observed').val(dst); // returns if DST is observed on summer $('#dst_observed').val(dst); // returns if DST is observed on summer
$('#dst_first').val(dst_first); // returns DST first switch in year $('#dst_first').val(dst_first); // returns DST first switch in year
$('#dst_second').val(dst_second); // returns DST second switch in year $('#dst_second').val(dst_second); // returns DST second switch in year

View File

@ -28,7 +28,11 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1;
// If we force to use jmobile, then we reenable javascript // If we force to use jmobile, then we reenable javascript
if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1;
$arrayofjs=array('/core/js/dst.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION))); // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
$arrayofjs=array(
'/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)),
'/core/js/dst.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION))
);
$titleofloginpage=$langs->trans('Login').' @ '.$title; // title is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page. $titleofloginpage=$langs->trans('Login').' @ '.$title; // title is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page.
print top_htmlhead('',$titleofloginpage,0,0,$arrayofjs); print top_htmlhead('',$titleofloginpage,0,0,$arrayofjs);

2
htdocs/includes/jstz/jstz.min.js vendored Normal file

File diff suppressed because one or more lines are too long