[wp-trac] [WordPress Trac] #32835: the number of weeks in a given year
WordPress Trac
noreply at wordpress.org
Tue Jun 30 07:11:30 UTC 2015
#32835: the number of weeks in a given year
-------------------------+-----------------------------
Reporter: luciole135 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32835>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list