Skip to content

Commit 2ac344f

Browse files
authored
Merge pull request #6826 from kenjis/change-default-timezone
config: change default timezone to UTC
2 parents b2342da + 458d4fd commit 2ac344f

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

app/Config/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class App extends BaseConfig
9797
* The default timezone that will be used in your application to display
9898
* dates with the date helper, and can be retrieved through app_timezone()
9999
*/
100-
public string $appTimezone = 'America/Chicago';
100+
public string $appTimezone = 'UTC';
101101

102102
/**
103103
* --------------------------------------------------------------------------

tests/system/CommonFunctionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function testInvisibleEncoded()
316316

317317
public function testAppTimezone()
318318
{
319-
$this->assertSame('America/Chicago', app_timezone());
319+
$this->assertSame('UTC', app_timezone());
320320
}
321321

322322
public function testCSRFToken()

tests/system/Debug/TimerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public function testThrowsExceptionStoppingNonTimer()
9494
$timer->stop('test1');
9595
}
9696

97+
/**
98+
* This test might fail if your timezone has Daylight Saving Time.
99+
* See https://github.com/codeigniter4/CodeIgniter4/issues/6823
100+
*/
97101
public function testLongExecutionTime()
98102
{
99103
$timer = new Timer();

tests/system/I18n/TimeLegacyTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,10 @@ public function testGetQuarter()
453453
public function testGetDST()
454454
{
455455
// America/Chicago. DST from early March -> early Nov
456-
$time = TimeLegacy::createFromDate(2012, 1, 1);
456+
$time = TimeLegacy::createFromDate(2012, 1, 1, 'America/Chicago');
457457
$this->assertFalse($time->dst);
458-
$time = TimeLegacy::createFromDate(2012, 9, 1);
458+
459+
$time = TimeLegacy::createFromDate(2012, 9, 1, 'America/Chicago');
459460
$this->assertTrue($time->dst);
460461
}
461462

tests/system/I18n/TimeTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ public function testGetTimestamp()
398398
$this->assertSame($expected, $time->timestamp);
399399
}
400400

401+
/**
402+
* This test might fail if your timezone has Daylight Saving Time.
403+
* See https://github.com/codeigniter4/CodeIgniter4/issues/6818
404+
*/
401405
public function testGetAge()
402406
{
403407
$time = Time::parse('5 years ago');
@@ -455,9 +459,10 @@ public function testGetQuarter()
455459
public function testGetDST()
456460
{
457461
// America/Chicago. DST from early March -> early Nov
458-
$time = Time::createFromDate(2012, 1, 1);
462+
$time = Time::createFromDate(2012, 1, 1, 'America/Chicago');
459463
$this->assertFalse($time->dst);
460-
$time = Time::createFromDate(2012, 9, 1);
464+
465+
$time = Time::createFromDate(2012, 9, 1, 'America/Chicago');
461466
$this->assertTrue($time->dst);
462467
}
463468

user_guide_src/source/changelogs/v4.3.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ Changes
264264
- Config
265265
- All atomic type properties in ``Config`` classes have been typed.
266266
- Changed the default setting to not redirect when a CSRF check fails so that it is easy to see that it is a CSRF error.
267+
- The default ``Config\App::$appTimezone`` has been changed to ``UTC`` to avoid being affected by daylight saving time.
267268
- DBDebug
268269
- To be consistent in behavior regardless of environments, ``Config\Database::$default['DBDebug']`` and ``Config\Database::$tests['DBDebug']`` has been changed to ``true`` by default. With these settings, an exception is always thrown when a database error occurs.
269270
- Now ``DatabaseException`` thrown in ``BaseBuilder`` is thrown if ``$DBDebug`` is true. Previously, it is thrown if ``CI_DEBUG`` is true.

0 commit comments

Comments
 (0)