Make WordPress Core

Changeset 34864


Ignore:
Timestamp:
10/06/2015 02:06:26 PM (9 years ago)
Author:
wonderboymusic
Message:

WP Mail: replace logic that was mimicking strtotime() with strtotime(). Without this, the date parsing wasn't accounting for half-hour and quarter-hour timezones.

Props neoscrib, solarissmoke.
Fixes #16993.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-mail.php

    r34343 r34864  
    129129            }
    130130
    131             if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
    132                 $ddate = trim($line);
    133                 $ddate = str_replace('Date: ', '', $ddate);
    134                 if (strpos($ddate, ',')) {
    135                     $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
    136                 }
    137                 $date_arr = explode(' ', $ddate);
    138                 $date_time = explode(':', $date_arr[3]);
    139 
    140                 $ddate_H = $date_time[0];
    141                 $ddate_i = $date_time[1];
    142                 $ddate_s = $date_time[2];
    143 
    144                 $ddate_m = $date_arr[1];
    145                 $ddate_d = $date_arr[0];
    146                 $ddate_Y = $date_arr[2];
    147                 for ( $j = 0; $j < 12; $j++ ) {
    148                     if ( $ddate_m == $dmonths[$j] ) {
    149                         $ddate_m = $j+1;
    150                     }
    151                 }
    152 
    153                 $time_zn = intval($date_arr[4]) * 36;
    154                 $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
    155                 $ddate_U = $ddate_U - $time_zn;
    156                 $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
    157                 $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
     131            if ( preg_match( '/Date: /i', $line ) ) { // of the form '20 Mar 2002 20:32:37 +0100'
     132                $ddate = str_replace( 'Date: ', '', trim( $line ) );
     133                $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime
     134                $ddate_U = strtotime( $ddate );
     135                $post_date = gmdate( 'Y-m-d H:i:s', $ddate_U + $time_difference );
     136                $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_U );
    158137            }
    159138        }
Note: See TracChangeset for help on using the changeset viewer.