WordPress.org

Make WordPress Core

Ticket #38771: Clarified_date_i18n_args_and_fixed_GMT_one_.patch

File Clarified_date_i18n_args_and_fixed_GMT_one_.patch, 2.2 KB (added by Rarst, 18 months ago)

Clarified arguments and fixed current narrow case of what GMT one does.

  • wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7070}
    7171
    7272/**
    73  * Retrieve the date in localized format, based on timestamp.
     73 * Retrieve the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds.
    7474 *
    7575 * If the locale specifies the locale month and weekday, then the locale will
    7676 * take over the format for the date. If it isn't, then the date format string
     
    8080 *
    8181 * @global WP_Locale $wp_locale
    8282 *
    83  * @param string   $dateformatstring Format to display the date.
    84  * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
    85  * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
     83 * @param string   $dateformatstring      Format to display the date.
     84 * @param bool|int $timestamp_with_offset Optional. Accepts a sum of Unix timestamp and timezone offset in seconds. Default false.
     85 * @param bool     $gmt                   Optional. Whether to use GMT timezone, only applies if timestamp is not provided. Default false.
    8686 *
    8787 * @return string The date, translated if locale specifies it.
    8888 */
    89 function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
     89function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = false ) {
    9090        global $wp_locale;
    91         $i = $unixtimestamp;
     91        $i = $timestamp_with_offset;
    9292
    9393        if ( false === $i ) {
    9494                $i = current_time( 'timestamp', $gmt );
     
    120120        $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
    121121        $timezone_formats_re = implode( '|', $timezone_formats );
    122122        if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
    123                 $timezone_string = get_option( 'timezone_string' );
     123                if ( false === $timestamp_with_offset && $gmt ) {
     124                        $timezone_string = 'UTC';
     125                } else {
     126                        $timezone_string = get_option( 'timezone_string' );
     127                }
    124128                if ( $timezone_string ) {
    125129                        $timezone_object = timezone_open( $timezone_string );
    126130                        $date_object = date_create( null, $timezone_object );