diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 5d336ccc2c23b..09f2d190bb829 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -75,7 +75,6 @@ function getServerTimeZoneString()
/**
* Return server timezone int.
- * 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 +82,7 @@ function getServerTimeZoneString()
function getServerTimeZoneInt($refgmtdate='now')
{
global $conf;
- if (method_exists('DateTimeZone','getOffset') && empty($conf->global->MAIN_OLD_DATE))
+ if (method_exists('DateTimeZone','getOffset'))
{
// 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');
@@ -97,11 +96,13 @@ function getServerTimeZoneInt($refgmtdate='now')
}
else
{
+ dol_print_error('','PHP version must be 5.2+');
+ /*
// 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 new PHP with not MAIN_OLD_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 but this may be a bug.
$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 +112,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 new PHP with not MAIN_OLD_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 but this may be a bug.
$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;
@@ -119,6 +120,7 @@ function getServerTimeZoneInt($refgmtdate='now')
return 'unknown'; // For true result
}
else $tmp=dol_mktime(0,0,0,1,1,1970);
+ */
}
$tz=round(($tmp<0?1:-1)*abs($tmp/3600));
return $tz;
@@ -146,7 +148,7 @@ function getParentCompanyTimeZoneString()
function getParentCompanyTimeZoneInt($refgmtdate='now')
{
global $conf;
- if (class_exists('DateTime') && empty($conf->global->MAIN_OLD_DATE))
+ if (class_exists('DateTime'))
{
// Method 1 (include daylight)
$localtz = new DateTimeZone(getParentCompanyTimeZoneString());
@@ -155,6 +157,7 @@ function getParentCompanyTimeZoneInt($refgmtdate='now')
}
else
{
+ dol_print_error('','PHP version must be 5.2+');
// Method 2 (does not include daylight)
$tmp=dol_mktime(0,0,0,1,1,1970);
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index db204b53ebd84..84bc527fbf3c7 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1023,7 +1023,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_OLD_DATE))
+ if (method_exists('DateTime','getTimestamp'))
{
if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get());
else $localtz = new DateTimeZone('UTC');
@@ -1034,6 +1034,8 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
}
else
{
+ dol_print_error('','PHP version must be 5.2+');
+ /*
$usealternatemethod=false;
if ($year <= 1970) $usealternatemethod=true; // <= 1970
if ($year >= 2038) $usealternatemethod=true; // >= 2038
@@ -1045,7 +1047,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
else
{
$date=mktime($hour,$minute,$second,$month,$day,$year);
- }
+ }*/
}
return $date;
}
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 1217facab5f8b..d768adf73f489 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -73,12 +73,12 @@
if (versioncompare(versionphparray(),array(4,3,10)) < 0) // Minimum to use (error if lower)
{
print ' '.$langs->trans("ErrorPHPVersionTooLow",'4.3.10');
- $checksok=0;
+ $checksok=0; // 0=error, 1=warning
}
-else if (versioncompare(versionphparray(),array(5,2,0)) < 0) // Minimum supported (warning if lower)
+else if (versioncompare(versionphparray(),array(5,2,0)) < 0) // Minimum supported (error if lower)
{
print ' '.$langs->trans("WarningPHPVersionTooLow",'5.2.0');
- $checksok=1;
+ $checksok=0; // 0=error, 1=warning
}
else
{
diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php
index 8cf7520f9fd0f..c68272eafb793 100644
--- a/test/phpunit/DateLibTest.php
+++ b/test/phpunit/DateLibTest.php
@@ -313,15 +313,6 @@ public function testDolStringToTime()
$langs=$this->savlangs;
$db=$this->savdb;
- $conf->global->MAIN_OLD_DATE=1;
-
- $stime='19700102';
- $result=dol_stringtotime($stime);
- print __METHOD__." result=".$result."\n";
- $this->assertEquals(86400,$result);
-
- $conf->global->MAIN_OLD_DATE=0;
-
$stime='19700102';
$result=dol_stringtotime($stime);
print __METHOD__." result=".$result."\n";