Make WordPress Core

Ticket #34835: Added_numeric_time_zone_offset_support_to_date_i18n1.patch

File Added_numeric_time_zone_offset_support_to_date_i18n1.patch, 1.5 KB (added by Rarst, 7 years ago)

Skipped I format for DST which is irrelevant for the case.

  • wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    132132                                        $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    133133                                }
    134134                        }
     135                } else {
     136                        $offset = get_option( 'gmt_offset' );
     137                        foreach ( $timezone_formats as $timezone_format ) {
     138                                if ( 'I' === $timezone_format ) {
     139                                        continue;
     140                                }
     141
     142                                if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
     143                                        if ( 'Z' === $timezone_format ) {
     144                                                $formatted = (string) ( $offset * HOUR_IN_SECONDS );
     145                                        } else {
     146                                                $prefix    = '';
     147                                                $hours     = (int) $offset;
     148                                                $separator = '';
     149                                                $minutes   = abs( ( $offset - $hours ) * 60 );
     150
     151                                                if ( 'T' === $timezone_format ) {
     152                                                        $prefix = 'GMT';
     153                                                } elseif ( 'e' === $timezone_format || 'P' === $timezone_format ) {
     154                                                        $separator = ':';
     155                                                }
     156
     157                                                $formatted = sprintf( '%s%+03d%s%02d', $prefix, $hours, $separator, $minutes );
     158                                        }
     159
     160                                        $dateformatstring = ' ' . $dateformatstring;
     161                                        $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
     162                                        $dateformatstring = substr( $dateformatstring, 1 );
     163                                }
     164                        }
    135165                }
    136166        }
    137167        $j = @date( $dateformatstring, $i );