Make WordPress Core

Changeset 33803


Ignore:
Timestamp:
08/29/2015 01:46:53 AM (9 years ago)
Author:
boonebgorges
Message:

Simplify the weeks-per-year calculation WP_Date_Query::validate_date_values().

Props luciole135.
Fixes #30845.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/date.php

    r32116 r33803  
    356356        // Weeks per year.
    357357        if ( isset( $_year ) ) {
    358             // If we have a specific year, use it to calculate number of weeks.
    359             $date = new DateTime();
    360             $date->setISODate( $_year, 53 );
    361             $week_count = $date->format( "W" ) === "53" ? 53 : 52;
     358            /*
     359             * If we have a specific year, use it to calculate number of weeks.
     360             * Note: the number of weeks in a year is the date in which Dec 28 appears.
     361             */
     362            $week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
    362363
    363364        } else {
Note: See TracChangeset for help on using the changeset viewer.