Simplify the weeks-per-year calculation `WP_Date_Query::validate_date_values()`.
Props luciole135. Fixes #30845. git-svn-id: https://develop.svn.wordpress.org/trunk@33803 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a47ee912ac
commit
5b0c402e6f
|
@ -355,10 +355,11 @@ class WP_Date_Query {
|
|||
|
||||
// Weeks per year.
|
||||
if ( isset( $_year ) ) {
|
||||
// If we have a specific year, use it to calculate number of weeks.
|
||||
$date = new DateTime();
|
||||
$date->setISODate( $_year, 53 );
|
||||
$week_count = $date->format( "W" ) === "53" ? 53 : 52;
|
||||
/*
|
||||
* If we have a specific year, use it to calculate number of weeks.
|
||||
* Note: the number of weeks in a year is the date in which Dec 28 appears.
|
||||
*/
|
||||
$week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
|
||||
|
||||
} else {
|
||||
// Otherwise set the week-count to a maximum of 53.
|
||||
|
|
Loading…
Reference in New Issue