Try a fix when timezone string is not standard
This commit is contained in:
parent
7ee1388582
commit
bf96a78f63
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011-2012 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>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
@ -18,7 +18,8 @@
|
||||
|
||||
//
|
||||
// \file htdocs/core/js/dst.js
|
||||
// \brief File that include javascript functions for detect user tz, dst_observed, dst_first, dst_second
|
||||
// \brief File that include javascript functions for detect user tz, tz_string, dst_observed, dst_first, dst_second,
|
||||
// screenwidth and screenheight
|
||||
//
|
||||
|
||||
$(document).ready(function () {
|
||||
@ -39,22 +40,22 @@ $(document).ready(function () {
|
||||
dst = "1"; // daylight savings time is observed
|
||||
}
|
||||
var now=new Date();
|
||||
var tz=now.toTimeString().match(/\(.*\)/);
|
||||
var tz=now.toTimeString().match(/\(.*\)/); // now.toTimeString may return "12:39:59 GMT+0200 (CEST)"
|
||||
//alert('date=' + now + ' string=' + now.toTimeString());
|
||||
var dst_first=DisplayDstSwitchDates('first');
|
||||
var dst_second=DisplayDstSwitchDates('second');
|
||||
//alert(dst);
|
||||
$('#tz').val(std_time_offset); // returns TZ
|
||||
// tz is null with IE
|
||||
$('#tz').val(std_time_offset); // returns TZ
|
||||
// tz is null with IE
|
||||
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_first').val(dst_first); // returns DST first switch in year
|
||||
$('#dst_second').val(dst_second); // returns DST second switch in year
|
||||
$('#dst_observed').val(dst); // returns if DST is observed on summer
|
||||
$('#dst_first').val(dst_first); // returns DST first switch in year
|
||||
$('#dst_second').val(dst_second); // returns DST second switch in year
|
||||
// Detect and save screen resolution
|
||||
$('#screenwidth').val($(window).width()); // returns width of browser viewport
|
||||
$('#screenheight').val($(window).height()); // returns width of browser viewport
|
||||
$('#screenwidth').val($(window).width()); // returns width of browser viewport
|
||||
$('#screenheight').val($(window).height()); // returns width of browser viewport
|
||||
});
|
||||
|
||||
function DisplayDstSwitchDates(firstsecond)
|
||||
|
||||
@ -886,7 +886,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg)
|
||||
|| preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg))
|
||||
{
|
||||
// This part of code should not be used.
|
||||
// This part of code should not be used. TODO Remove this.
|
||||
dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING);
|
||||
// Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS'
|
||||
$syear = (! empty($reg[1]) ? $reg[1] : '');
|
||||
@ -904,7 +904,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
// Date is a timestamps
|
||||
if ($time < 100000000000) // Protection against bad date values
|
||||
{
|
||||
$ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt);
|
||||
$ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); // TODO Remove this
|
||||
}
|
||||
else $ret='Bad value '.$time.' for date';
|
||||
}
|
||||
@ -912,7 +912,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
if (preg_match('/__b__/i',$format))
|
||||
{
|
||||
// Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs.
|
||||
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst);
|
||||
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Remove this
|
||||
if ($encodetooutput)
|
||||
{
|
||||
$monthtext=$outputlangs->transnoentities('Month'.$month);
|
||||
@ -931,7 +931,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
}
|
||||
if (preg_match('/__a__/i',$format))
|
||||
{
|
||||
$w=adodb_strftime('%w',$time+$offsettz+$offsetdst);
|
||||
$w=adodb_strftime('%w',$time+$offsettz+$offsetdst); // TODO Remove this
|
||||
$dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w);
|
||||
$ret=str_replace('__A__',$dayweek,$ret);
|
||||
$ret=str_replace('__a__',dol_substr($dayweek,0,3),$ret);
|
||||
@ -1037,8 +1037,16 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
}
|
||||
else if ($gm === 'user')
|
||||
{
|
||||
$default_timezone=(empty($_SESSION["dol_tz_string"])?'UTC':$_SESSION["dol_tz_string"]);
|
||||
$localtz = new DateTimeZone($default_timezone);
|
||||
// We use dol_tz_string first because it contains dst.
|
||||
$default_timezone=(empty($_SESSION["dol_tz_string"])?@date_default_timezone_get():$_SESSION["dol_tz_string"]);
|
||||
try {
|
||||
$localtz = new DateTimeZone($default_timezone);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING);
|
||||
$default_timezone=@date_default_timezone_get();
|
||||
}
|
||||
}
|
||||
else $localtz = new DateTimeZone('UTC');
|
||||
$dt = new DateTime(null,$localtz);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -447,6 +447,9 @@ if (! defined('NOLOGIN'))
|
||||
$dol_authmode=$conf->authmode; // This properties is defined only when logged, to say what mode was successfully used
|
||||
$dol_tz=$_POST["tz"];
|
||||
$dol_tz_string=$_POST["tz_string"];
|
||||
$dol_tz_string=preg_replace('\s*\(.+\)$','',$dol_tz_string);
|
||||
$dol_tz_string=preg_replace(',','/',$dol_tz_string);
|
||||
$dol_tz_string=preg_replace('\s','_',$dol_tz_string);
|
||||
$dol_dst=0;
|
||||
if (isset($_POST["dst_first"]) && isset($_POST["dst_second"]))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user