Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#30845 closed enhancement (fixed)

the number of weeks in a given year

Reported by: luciole135's profile luciole135 Owned by: boonebgorges's profile boonebgorges
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.1
Component: Date/Time Keywords: has-patch
Focuses: Cc:

Description

Firstly my apologies if I'm wrong place.
I propose a correction of the function validate_date_values ($date_query = array()) of the /wp-includes/date.php file
the following 341 to 343 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?));

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 (2)

30845.patch (798 bytes) - added by luciole135 10 years ago.
number of weeks in a given year
30845.2.patch (552 bytes) - added by luciole135 9 years ago.
patch for WordPress 4.3

Download all attachments as: .zip

Change History (7)

#1 @luciole135
10 years ago

  • Type changed from feature request to enhancement

@luciole135
10 years ago

number of weeks in a given year

#2 @luciole135
9 years ago

  • Keywords has-patch added

#3 @morganestes
9 years ago

#32835 was marked as a duplicate.

@luciole135
9 years ago

patch for WordPress 4.3

#4 @boonebgorges
9 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 33803:

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

Props luciole135.
Fixes #30845.

#5 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.4
Note: See TracTickets for help on using tickets.