Skip to content

Commit

Permalink
WP Mail: replace logic that was mimicking strtotime() with `strtoti…
Browse files Browse the repository at this point in the history
…me()`. Without this, the date parsing wasn't accounting for half-hour and quarter-hour timezones.

 
Props neoscrib, solarissmoke.
Fixes #16993.


git-svn-id: https://develop.svn.wordpress.org/trunk@34864 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
staylor committed Oct 6, 2015
1 parent d257aeb commit f8b7bba
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions src/wp-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,12 @@
}
}

if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
$ddate = trim($line);
$ddate = str_replace('Date: ', '', $ddate);
if (strpos($ddate, ',')) {
$ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
}
$date_arr = explode(' ', $ddate);
$date_time = explode(':', $date_arr[3]);

$ddate_H = $date_time[0];
$ddate_i = $date_time[1];
$ddate_s = $date_time[2];

$ddate_m = $date_arr[1];
$ddate_d = $date_arr[0];
$ddate_Y = $date_arr[2];
for ( $j = 0; $j < 12; $j++ ) {
if ( $ddate_m == $dmonths[$j] ) {
$ddate_m = $j+1;
}
}

$time_zn = intval($date_arr[4]) * 36;
$ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
$ddate_U = $ddate_U - $time_zn;
$post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
$post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
if ( preg_match( '/Date: /i', $line ) ) { // of the form '20 Mar 2002 20:32:37 +0100'
$ddate = str_replace( 'Date: ', '', trim( $line ) );
$ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime
$ddate_U = strtotime( $ddate );
$post_date = gmdate( 'Y-m-d H:i:s', $ddate_U + $time_difference );
$post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_U );
}
}
}
Expand Down

0 comments on commit f8b7bba

Please sign in to comment.