2
0
forked from Wavyzz/dolibarr

First change to use native date functions instead of adodb

This commit is contained in:
Laurent Destailleur
2012-06-27 10:58:51 +02:00
parent aa649c167d
commit 2ab416889a
2 changed files with 6 additions and 6 deletions

View File

@@ -75,7 +75,7 @@ function getServerTimeZoneString()
/** /**
* Return server timezone int. * 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') * @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) * @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') function getServerTimeZoneInt($refgmtdate='now')
{ {
global $conf; 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) // 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');
@@ -101,7 +101,7 @@ function getServerTimeZoneInt($refgmtdate='now')
if ($refgmtdate == 'now') if ($refgmtdate == 'now')
{ {
if (ini_get("date.timezone")=='UTC') return 0; 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'); $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;
@@ -111,7 +111,7 @@ function getServerTimeZoneInt($refgmtdate='now')
elseif ($refgmtdate == 'summer') elseif ($refgmtdate == 'summer')
{ {
if (ini_get("date.timezone")=='UTC') return 0; 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'; $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;
@@ -146,7 +146,7 @@ function getParentCompanyTimeZoneString()
function getParentCompanyTimeZoneInt($refgmtdate='now') function getParentCompanyTimeZoneInt($refgmtdate='now')
{ {
global $conf; 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) // Method 1 (include daylight)
$localtz = new DateTimeZone(getParentCompanyTimeZoneString()); $localtz = new DateTimeZone(getParentCompanyTimeZoneString());

View File

@@ -960,7 +960,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
if ($second< 0 || $second > 60) return ''; 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()); if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get());
else $localtz = new DateTimeZone('UTC'); else $localtz = new DateTimeZone('UTC');