mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-04 16:12:39 +01:00
FIX Timezone problems
This commit is contained in:
@@ -68,7 +68,13 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
$langs->load("admin");
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
|
||||
print "\n".$langs->trans("CurrentTimeZone").' : '.getServerTimeZoneString();
|
||||
print "\n".$langs->trans("CurrentHour").' : '.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver');
|
||||
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
@@ -138,8 +144,8 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$db=$this->savdb;
|
||||
|
||||
// With same hours
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2012);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2012);
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2012, 'gmt');
|
||||
|
||||
$result=num_between_day($date1, $date2, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -150,8 +156,8 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
// With different hours
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2012);
|
||||
$date2=dol_mktime(12, 0, 0, 1, 2, 2012);
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt');
|
||||
$date2=dol_mktime(12, 0, 0, 1, 2, 2012, 'gmt');
|
||||
|
||||
$result=num_between_day($date1, $date2, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -190,25 +196,26 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$db=$this->savdb;
|
||||
|
||||
// With same hours - Tuesday/Wednesday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013);
|
||||
$date3=dol_mktime(0, 0, 0, 1, 3, 2013);
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt');
|
||||
$date3=dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt');
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." for Tuesday 1 - Wednesday 2 jan 2013 for FR result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 closed days (country france)
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." for Tuesday 1 - Wednesday 2 jan 2013 for XX result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 closed days (country unknown)
|
||||
|
||||
print '----'."\n";
|
||||
$result=num_public_holiday($date2, $date3, 'FR', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." for Wednesday 2 - Thursday 3 jan 2013 for FR result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'NumPublicHoliday for Wednesday 2 - Thursday 3 jan 2013 for FR'); // no closed days
|
||||
|
||||
// Check with easter monday
|
||||
$date1=dol_mktime(0, 0, 0, 4, 21, 2019);
|
||||
$date2=dol_mktime(0, 0, 0, 4, 23, 2019);
|
||||
$date1=dol_mktime(0, 0, 0, 4, 21, 2019, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 4, 23, 2019, 'gmt');
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -219,8 +226,8 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(2, $result, 'NumPublicHoliday including eastermonday for FR'); // 1 opened day, 2 closed days (sunday + easter monday)
|
||||
|
||||
// Check for sunday/saturday - Friday 4 - Sunday 6 jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013);
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt');
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -257,9 +264,9 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$db=$this->savdb;
|
||||
|
||||
// With same hours - Tuesday/Wednesday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013);
|
||||
$date3=dol_mktime(0, 0, 0, 1, 3, 2013);
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt');
|
||||
$date3=dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt');
|
||||
|
||||
$result=num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -274,8 +281,8 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(2, $result, 'NumOpenDay Wednesday 2 - Thursday 3 jan 2013 for FR'); // 2 opened days
|
||||
|
||||
// With same hours - Friday/Sunday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013);
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt');
|
||||
|
||||
$result=num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -325,7 +332,7 @@ class DateLibTest extends PHPUnit\Framework\TestCase
|
||||
|
||||
$result=convertSecondToTime(86400, 'all', 86400);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertSame('1 '.$langs->trans("Day"), $result);
|
||||
$this->assertSame('1 '.strtolower(dol_substr($langs->trans("Day"), 0, 1).'.'), $result);
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user