mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-08 18:12:53 +01:00
Qual: Still working on cleaning code for timezone management.
This commit is contained in:
@@ -368,7 +368,13 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
public function testDolMkTime()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$savtz=date_default_timezone_get();
|
||||
|
||||
// Some test for UTC TZ
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Check bad hours
|
||||
$result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
@@ -394,17 +400,20 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
$tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter)
|
||||
$this->assertEquals(7200-($tz*3600),$result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
|
||||
|
||||
// Some test for local TZ Europe/Paris
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
|
||||
// Check that tz for paris in winter is used
|
||||
$conf->global->MAIN_SERVER_TZ='Europe/Paris';
|
||||
$result=dol_mktime(2,0,0,1,1,1970,'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(3600,$result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris
|
||||
|
||||
// Check that daylight saving time is used
|
||||
$conf->global->MAIN_SERVER_TZ='Europe/Paris';
|
||||
$result=dol_mktime(2,0,0,6,1,2014,0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1401588000-3600-3600,$result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
|
||||
|
||||
date_default_timezone_set($savtz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user