From 5b0c402e6fa7cf31874be9dbc2b07bbde9d392f2 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 29 Aug 2015 01:46:53 +0000 Subject: [PATCH] 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 --- src/wp-includes/date.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/date.php b/src/wp-includes/date.php index 2e903a2518..9f64747bb3 100644 --- a/src/wp-includes/date.php +++ b/src/wp-includes/date.php @@ -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.