From 31560e19df0187655788c5f8a5d88e0de9a3b42c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Jun 2012 12:54:34 +0200 Subject: [PATCH] Fix with PHP 5.2 --- htdocs/core/lib/date.lib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index cdf8cc1b9b8..7ee142cbe46 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -83,7 +83,7 @@ function getServerTimeZoneString() function getServerTimeZoneInt($refgmtdate='now') { 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) $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) 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. $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; 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); - return 'unknown'; + return 'unknown'; // For true result } 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. $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; 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); - return 'unknown'; + return 'unknown'; // For true result } else $tmp=dol_mktime(0,0,0,1,1,1970); }