mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 06:37:06 +00:00
Date/Time: Replace all instances of date() with gmdate().
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed). `gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs. Props nielsdeblaauw, Rarst. Fixes #46438. See #44491. git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
public function test_should_format_date() {
|
||||
$this->assertEquals( strtotime( date( 'Y-m-d H:i:s' ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
|
||||
}
|
||||
|
||||
public function test_should_use_custom_timestamp() {
|
||||
@@ -14,7 +14,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_should_be_in_gmt() {
|
||||
$this->assertEquals( strtotime( date( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( strtotime( gmdate( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
|
||||
}
|
||||
|
||||
public function test_custom_timestamp_ignores_gmt_setting() {
|
||||
@@ -24,13 +24,13 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
public function test_custom_timezone_setting() {
|
||||
update_option( 'timezone_string', 'America/Regina' );
|
||||
|
||||
$this->assertEquals( strtotime( date( 'Y-m-d H:i:s', time() + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( strtotime( gmdate( 'Y-m-d H:i:s', time() + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
|
||||
}
|
||||
|
||||
public function test_date_should_be_in_gmt_with_custom_timezone_setting() {
|
||||
update_option( 'timezone_string', 'America/Regina' );
|
||||
|
||||
$this->assertEquals( strtotime( date( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( strtotime( gmdate( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
|
||||
}
|
||||
|
||||
public function test_date_should_be_in_gmt_with_custom_timezone_setting_and_timestamp() {
|
||||
|
||||
Reference in New Issue
Block a user