mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-22183 lib: More unit tests for next day start.
This commit is contained in:
parent
3cdc35b44d
commit
3b873397e6
@ -388,6 +388,22 @@ class core_statslib_testcase extends advanced_testcase {
|
||||
public function test_statslib_get_next_day_start() {
|
||||
$this->setTimezone(0);
|
||||
$this->assertEquals(1272758400, stats_get_next_day_start(1272686410));
|
||||
|
||||
// Try setting timezone to some place in the US.
|
||||
$this->setTimezone('America/New_York', 'America/New_York');
|
||||
// Then set the time for midnight before daylight savings.
|
||||
// 1425790800 is midnight in New York (2015-03-08) Daylight saving will occur in 2 hours time.
|
||||
// 1425873600 is midnight the next day.
|
||||
$this->assertEquals(1425873600, stats_get_next_day_start(1425790800));
|
||||
$this->assertEquals(23, ((1425873600 - 1425790800) / 60 ) / 60);
|
||||
// Then set the time for midnight before daylight savings ends.
|
||||
// 1446350400 is midnight in New York (2015-11-01) Daylight saving will finish in 2 hours time.
|
||||
// 1446440400 is midnight the next day.
|
||||
$this->assertEquals(1446440400, stats_get_next_day_start(1446350400));
|
||||
$this->assertEquals(25, ((1446440400 - 1446350400) / 60 ) / 60);
|
||||
// The next day should be normal.
|
||||
$this->assertEquals(1446526800, stats_get_next_day_start(1446440400));
|
||||
$this->assertEquals(24, ((1446526800 - 1446440400) / 60 ) / 60);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user