Corrected Timezone detection by using jstz external library
This commit is contained in:
parent
8df56511be
commit
1e05262884
@ -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
|
||||||
|
|||||||
@ -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,7 +24,10 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// Detect and save TZ and DST
|
|
||||||
|
var timezone = jstz.determine();
|
||||||
|
|
||||||
|
// 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);
|
||||||
var temp = jan1.toGMTString();
|
var temp = jan1.toGMTString();
|
||||||
@ -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
|
||||||
|
|||||||
@ -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
2
htdocs/includes/jstz/jstz.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user