Fix with PHP 5.2
This commit is contained in:
parent
5ce0fe1405
commit
31560e19df
@ -83,7 +83,7 @@ function getServerTimeZoneString()
|
|||||||
function getServerTimeZoneInt($refgmtdate='now')
|
function getServerTimeZoneInt($refgmtdate='now')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if (class_exists('DateTime') && ! empty($conf->global->MAIN_NEW_DATE))
|
if (method_exists('DateTimeZone','getOffset') && ! empty($conf->global->MAIN_NEW_DATE))
|
||||||
{
|
{
|
||||||
// Method 1 (include daylight)
|
// Method 1 (include daylight)
|
||||||
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
|
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
|
||||||
@ -100,21 +100,23 @@ function getServerTimeZoneInt($refgmtdate='now')
|
|||||||
// Method 2 (does not include daylight, not supported by adodb)
|
// Method 2 (does not include daylight, not supported by adodb)
|
||||||
if ($refgmtdate == 'now')
|
if ($refgmtdate == 'now')
|
||||||
{
|
{
|
||||||
|
if (ini_get("date.timezone")=='UTC') return 0;
|
||||||
// We don't know server timezone string, so we don't know location, so we can't guess daylight. We assume we use same than client. Fix is to use MAIN_NEW_DATE.
|
// We don't know server timezone string, so we don't know location, so we can't guess daylight. We assume we use same than client. Fix is to use MAIN_NEW_DATE.
|
||||||
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
|
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
|
||||||
if (dol_stringtotime($_SESSION['dol_dst_first']) <= $gmtnow && $gmtnow < dol_stringtotime($_SESSION['dol_dst_second'])) $daylight=1;
|
if (dol_stringtotime($_SESSION['dol_dst_first']) <= $gmtnow && $gmtnow < dol_stringtotime($_SESSION['dol_dst_second'])) $daylight=1;
|
||||||
else $daylight=0;
|
else $daylight=0;
|
||||||
$tmp=dol_mktime(0,0,0,$monthref,$dayref,$yearref,false,0)-dol_mktime(0,0,0,$monthref,$dayref,$yearref,true,0)-($daylight*3600);
|
$tmp=dol_mktime(0,0,0,$monthref,$dayref,$yearref,false,0)-dol_mktime(0,0,0,$monthref,$dayref,$yearref,true,0)-($daylight*3600);
|
||||||
return 'unknown';
|
return 'unknown'; // For true result
|
||||||
}
|
}
|
||||||
elseif ($refgmtdate == 'summer')
|
elseif ($refgmtdate == 'summer')
|
||||||
{
|
{
|
||||||
|
if (ini_get("date.timezone")=='UTC') return 0;
|
||||||
// We don't know server timezone string, so we don't know location, so we can't guess daylight. We assume we use same than client. Fix is to use MAIN_NEW_DATE.
|
// We don't know server timezone string, so we don't know location, so we can't guess daylight. We assume we use same than client. Fix is to use MAIN_NEW_DATE.
|
||||||
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref='08'; $dayref='01';
|
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref='08'; $dayref='01';
|
||||||
if (dol_stringtotime($_SESSION['dol_dst_first']) <= dol_stringtotime($yearref.'-'.$monthref.'-'.$dayref) && dol_stringtotime($yearref.'-'.$monthref.'-'.$dayref) < dol_stringtotime($_SESSION['dol_dst_second'])) $daylight=1;
|
if (dol_stringtotime($_SESSION['dol_dst_first']) <= dol_stringtotime($yearref.'-'.$monthref.'-'.$dayref) && dol_stringtotime($yearref.'-'.$monthref.'-'.$dayref) < dol_stringtotime($_SESSION['dol_dst_second'])) $daylight=1;
|
||||||
else $daylight=0;
|
else $daylight=0;
|
||||||
$tmp=dol_mktime(0,0,0,$monthref,$dayref,$yearref,false,0)-dol_mktime(0,0,0,$monthref,$dayref,$yearref,true,0)-($daylight*3600);
|
$tmp=dol_mktime(0,0,0,$monthref,$dayref,$yearref,false,0)-dol_mktime(0,0,0,$monthref,$dayref,$yearref,true,0)-($daylight*3600);
|
||||||
return 'unknown';
|
return 'unknown'; // For true result
|
||||||
}
|
}
|
||||||
else $tmp=dol_mktime(0,0,0,1,1,1970);
|
else $tmp=dol_mktime(0,0,0,1,1,1970);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user