mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 03:04:34 +00:00
Formatting: allow date strings to be passed to get_gmt_from_date(), instead of requiring 'Y-m-d H:i:s'.
Adds unit tests. Props pbearne. Fixes #34279. git-svn-id: https://develop.svn.wordpress.org/trunk@35284 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -47,4 +47,50 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
$gmt = '2012-06-01 11:34:56';
|
||||
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_date_and_time_from_gmt_no_timezone() {
|
||||
$gmt = $local = '2012-01-01 12:34:56';
|
||||
$this->assertEquals( $gmt, get_date_from_gmt( $local ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_no_timezone() {
|
||||
$gmt = '2012-12-01 00:00:00';
|
||||
$date = '2012-12-01';
|
||||
$this->assertEquals( $gmt, get_gmt_from_date( $date ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_short_date() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = '2012-12-01';
|
||||
$gmt = '2012-12-01 00:00:00';
|
||||
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_string_date() {
|
||||
update_option( 'timezone_string', 'Europe/London' );
|
||||
$local = 'now';
|
||||
$gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
|
||||
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34279
|
||||
*/
|
||||
function test_get_gmt_from_date_string_date_no_timezone() {
|
||||
$local = 'now';
|
||||
$gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
|
||||
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user