WordPress.org

Make WordPress Core

Ticket #30845: 30845.patch

File 30845.patch, 798 bytes (added by luciole135, 5 years ago)

number of weeks in a given year

  • src/wp-includes/date.php

     
    336336                );
    337337
    338338                // Weeks per year.
    339                 if ( array_key_exists( 'year', $date_query ) ) {
    340                         // If we have a specific year, use it to calculate number of weeks.
    341                         $date = new DateTime();
    342                         $date->setISODate( $date_query['year'], 53 );
    343                         $week_count = $date->format( "W" ) === "53" ? 53 : 52;
    344 
    345                 } else {
    346                         // Otherwise set the week-count to a maximum of 53.
    347                         $week_count = 53;
    348                 }
    349 
     339                $week_count = (array_key_exists('year', $date_query) ? date('W',mktime(0,0,0,12,28,$date_query['year'])) : 53);
    350340                $min_max_checks['week'] = array(
    351341                        'min' => 1,
    352342                        'max' => $week_count