Introduced dayofweek_iso time param for WP_Date_Query.

The initial `dayofweek` param sets day 1 to Sunday. This is out of step with
ISO standards, which calls Monday day 1. To maintain backward compatibility
with the existing parameter, we introduce the new `dayofweek_iso` for the
new, more compliant param.

Props mboynes.
Fixes #28063.

git-svn-id: https://develop.svn.wordpress.org/trunk@30142 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2014-11-01 03:23:15 +00:00
parent d6b7b7aa41
commit 7c64b3b3dd
3 changed files with 50 additions and 2 deletions

View File

@@ -635,6 +635,24 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
$this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) );
}
/**
* @ticket 28063
*/
public function test_date_query_dayofweek_iso() {
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) );
$posts = $this->_get_query_result( array(
'date_query' => array(
array(
'dayofweek_iso' => 5,
),
),
) );
$this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) );
}
public function test_date_query_hour() {
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) );
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) );