Skip to content

Commit c199ff8

Browse files
committed
Restore PHP datetime.format.php documentation comments
The PHP manual references for format specifiers used by gmdate() were accidentally removed when adding zero-date handling. These comments document why specific format characters (n, Y, j) are used in the fallback path and should be preserved.
1 parent 8e2c32f commit c199ff8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

wp-includes/sqlite/class-wp-sqlite-pdo-user-defined-functions.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ public function month( $field ) {
246246
if ( preg_match( '/\d{4}-(\d{2})/', $field, $matches ) ) {
247247
return intval( $matches[1] );
248248
}
249+
/*
250+
* From https://www.php.net/manual/en/datetime.format.php:
251+
*
252+
* n - Numeric representation of a month, without leading zeros.
253+
* 1 through 12
254+
*/
249255
return intval( gmdate( 'n', strtotime( $field ) ) );
250256
}
251257

@@ -264,6 +270,11 @@ public function year( $field ) {
264270
if ( preg_match( '/(\d{4})-\d{2}/', $field, $matches ) ) {
265271
return intval( $matches[1] );
266272
}
273+
/*
274+
* From https://www.php.net/manual/en/datetime.format.php:
275+
*
276+
* Y - A full numeric representation of a year, 4 digits.
277+
*/
267278
return intval( gmdate( 'Y', strtotime( $field ) ) );
268279
}
269280

@@ -283,6 +294,12 @@ public function day( $field ) {
283294
if ( preg_match( '/\d{4}-\d{2}-(\d{2})/', $field, $matches ) ) {
284295
return intval( $matches[1] );
285296
}
297+
/*
298+
* From https://www.php.net/manual/en/datetime.format.php:
299+
*
300+
* j - Day of the month without leading zeros.
301+
* 1 to 31.
302+
*/
286303
return intval( gmdate( 'j', strtotime( $field ) ) );
287304
}
288305

0 commit comments

Comments
 (0)