WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32835 closed enhancement (duplicate)

the number of weeks in a given year

Reported by: luciole135 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Date/Time Keywords: has-patch
Focuses: Cc:
PR Number:

Description

I propose a correction of the function validate_date_values ($date_query = array()) of the /wp-includes/date.php file
the following 359 to 361 lines:

$date = new DateTime();
$date-> setISODate ($date_query year?, 53);
$week_count = $date-> format ('W') = '53'? 53: 52;

may be replaced by a single line (without using the class dateTime):

$week_count = date ('W', mktime (0,0,0,12,28,$date_query year?));

This speeds up the execution of about 1/100 sec because it greatly simplifies the calculations.

Indeed, the number of weeks in a given year is equal to the corresponding week number of 28 December.
http://en.Wikipedia.org/wiki/ISO_week_date

Attachments (1)

32835.patch (600 bytes) - added by luciole135 4 years ago.

Download all attachments as: .zip

Change History (4)

@luciole135
4 years ago

#1 @luciole135
4 years ago

  • Keywords has-patch added

#2 @morganestes
4 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #30845.

#3 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.