Skip to content

Commit 0c1d48a

Browse files
Date/Time: Fix swapped variable names and comments in get_weekstartend().
The variables `$mm` and `$md` had their substr() positions and inline comments swapped — `$mm` was extracting the day digits (position 8) while `$md` was extracting the month digits (position 5), contrary to what the comments indicated. The output was accidentally correct because the two mistakes cancelled each other out in the mktime() call, but the misleading naming posed a future maintenance risk. Corrects the substr() positions and mktime() argument order so that variable names, comments, and logic are all consistent.
1 parent e12ddb3 commit 0c1d48a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/wp-includes/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,13 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
589589
$my = substr( $mysqlstring, 0, 4 );
590590

591591
// MySQL string month.
592-
$mm = substr( $mysqlstring, 8, 2 );
592+
$mm = substr( $mysqlstring, 5, 2 );
593593

594594
// MySQL string day.
595-
$md = substr( $mysqlstring, 5, 2 );
595+
$md = substr( $mysqlstring, 8, 2 );
596596

597597
// The timestamp for MySQL string day.
598-
$day = mktime( 0, 0, 0, $md, $mm, $my );
598+
$day = mktime( 0, 0, 0, $mm, $md, $my );
599599

600600
// The day of the week from the timestamp.
601601
$weekday = (int) gmdate( 'w', $day );

0 commit comments

Comments
 (0)