From ffdef38f5b3768ac80a21c95ba9f6e621cd3af4e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 17 Oct 2016 08:10:30 +0000 Subject: [PATCH] Date/Time: Remove some legacy logic in `date_i18n()`. Since there's no difference between using `date()` and `gmdate()` in WordPress, we can simply use the former in `date_i18n()` to reduce its complexity. Adds tests. Props jdgrimes for initial patch. Fixes #37910. Built from https://develop.svn.wordpress.org/trunk@38804 git-svn-id: http://core.svn.wordpress.org/trunk@38747 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 20 ++++++-------------- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 292abf9355..a434ea5622 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -91,13 +91,7 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { $i = $unixtimestamp; if ( false === $i ) { - if ( ! $gmt ) - $i = current_time( 'timestamp' ); - else - $i = time(); - // we should not let date() interfere with our - // specially computed timestamp - $gmt = true; + $i = current_time( 'timestamp', $gmt ); } /* @@ -106,15 +100,13 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { */ $req_format = $dateformatstring; - $datefunc = $gmt? 'gmdate' : 'date'; - if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { - $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); + $datemonth = $wp_locale->get_month( date( 'm', $i ) ); $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); - $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) ); + $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); - $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) ); - $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) ); + $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); + $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); $dateformatstring = ' '.$dateformatstring; $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); @@ -142,7 +134,7 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { } } } - $j = @$datefunc( $dateformatstring, $i ); + $j = @date( $dateformatstring, $i ); /** * Filters the date formatted based on the locale. diff --git a/wp-includes/version.php b/wp-includes/version.php index 6e429270db..41ec9cb674 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38803'; +$wp_version = '4.7-alpha-38804'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.