From 2ab416889a5cc61f06bcfceda16a841bf87e88ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Jun 2012 10:58:51 +0200 Subject: [PATCH] First change to use native date functions instead of adodb --- htdocs/core/lib/date.lib.php | 10 +++++----- htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index d412ec3ea82..b021db48448 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -75,7 +75,7 @@ function getServerTimeZoneString() /** * Return server timezone int. - * If $conf->global->MAIN_NEW_DATE is set, we use new behaviour: All convertions take care of dayling saving time. + * If $conf->global->MAIN_OLD_DATE is set or PHP too old, we use old behaviour: All convertions does not take care of dayling saving time. * * @param string $refgmtdate Reference period for timezone (timezone differs on winter and summer. May be 'now', 'winter' or 'summer') * @return int An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer) @@ -83,7 +83,7 @@ function getServerTimeZoneString() function getServerTimeZoneInt($refgmtdate='now') { global $conf; - if (method_exists('DateTimeZone','getOffset') && ! empty($conf->global->MAIN_NEW_DATE)) + if (method_exists('DateTimeZone','getOffset') && empty($conf->global->MAIN_OLD_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'); @@ -101,7 +101,7 @@ function getServerTimeZoneInt($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 new PHP with not MAIN_OLD_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; @@ -111,7 +111,7 @@ function getServerTimeZoneInt($refgmtdate='now') 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 new PHP with not MAIN_OLD_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; @@ -146,7 +146,7 @@ function getParentCompanyTimeZoneString() function getParentCompanyTimeZoneInt($refgmtdate='now') { global $conf; - if (class_exists('DateTime') && ! empty($conf->global->MAIN_NEW_DATE)) + if (class_exists('DateTime') && empty($conf->global->MAIN_OLD_DATE)) { // Method 1 (include daylight) $localtz = new DateTimeZone(getParentCompanyTimeZoneString()); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9f2177129cd..db2cbd3e80d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -960,7 +960,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) if ($second< 0 || $second > 60) return ''; } - if (method_exists('DateTime','getTimestamp') && ! empty($conf->global->MAIN_NEW_DATE)) + if (method_exists('DateTime','getTimestamp') && empty($conf->global->MAIN_OLD_DATE)) { if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get()); else $localtz = new DateTimeZone('UTC');