Changeset 30142
- Timestamp:
- 11/01/2014 03:23:15 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/date.php
r29938 r30142 61 61 * @var array 62 62 */ 63 public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', ' hour', 'minute', 'second' );63 public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' ); 64 64 65 65 /** … … 68 68 * @since 3.7.0 69 69 * @since 4.0.0 The $inclusive logic was updated to include all times within the date range. 70 * @since 4.1.0 Introduced 'dayofweek_iso' time type parameter. 70 71 * @access public 71 72 * … … 117 118 * @type int $dayofyear Optional. The day number of the year. Default empty. Accepts numbers 1-366. 118 119 * @type int $day Optional. The day of the month. Default empty. Accepts numbers 1-31. 119 * @type int $dayofweek Optional. The day number of the week. Default empty. Accepts numbers 1-7. 120 * @type int $dayofweek Optional. The day number of the week. Default empty. Accepts numbers 1-7 (1 is Sunday). 121 * @type int $dayofweek_iso Optional. The day number of the week (ISO). Default empty. 122 * Accepts numbers 1-7 (1 is Monday). 120 123 * @type int $hour Optional. The hour of the day. Default empty. Accepts numbers 0-23. 121 124 * @type int $minute Optional. The minute of the hour. Default empty. Accepts numbers 0-60. … … 310 313 // Days per week. 311 314 $min_max_checks['dayofweek'] = array( 315 'min' => 1, 316 'max' => 7 317 ); 318 319 // Days per week. 320 $min_max_checks['dayofweek_iso'] = array( 312 321 'min' => 1, 313 322 'max' => 7 … … 728 737 $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; 729 738 739 if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) 740 $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; 741 730 742 if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) { 731 743 // Avoid notices. -
trunk/tests/phpunit/tests/date/query.php
r29933 r30142 926 926 927 927 /** 928 * @ticket 28063 929 * @expectedIncorrectUsage WP_Date_Query 930 */ 931 public function test_validate_date_values_day_of_week_iso() { 932 // Valid values. 933 $days_of_week = range( 1, 7 ); 934 foreach ( $days_of_week as $day_of_week ) { 935 $this->assertTrue( $this->q->validate_date_values( array( 'dayofweek_iso' => $day_of_week ) ) ); 936 } 937 938 // Invalid values. 939 $days_of_week = array( -1, 0, 8 ); 940 foreach ( $days_of_week as $day_of_week ) { 941 $this->assertFalse( $this->q->validate_date_values( array( 'dayofweek_iso' => $day_of_week ) ) ); 942 } 943 } 944 945 /** 928 946 * @ticket 25834 929 947 * @expectedIncorrectUsage WP_Date_Query -
trunk/tests/phpunit/tests/query/dateQuery.php
r29993 r30142 629 629 array( 630 630 'dayofweek' => 3, 631 ), 632 ), 633 ) ); 634 635 $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); 636 } 637 638 /** 639 * @ticket 28063 640 */ 641 public function test_date_query_dayofweek_iso() { 642 $p1 = $this->factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) ); 643 $p2 = $this->factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) ); 644 645 $posts = $this->_get_query_result( array( 646 'date_query' => array( 647 array( 648 'dayofweek_iso' => 5, 631 649 ), 632 650 ),
Note: See TracChangeset
for help on using the changeset viewer.