Ticket #16495: formatting.php.patch
| File formatting.php.patch, 1.1 KB (added by , 15 years ago) |
|---|
-
wp-includes/formatting.php
1678 1678 */ 1679 1679 function iso8601_to_datetime($date_string, $timezone = 'user') { 1680 1680 $timezone = strtolower($timezone); 1681 $regex = '#([0-9]{4})-?([0-9]{2})-?([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.\d+)(Z|[\+|\-][0-9]{2,4}){0,1}#'; 1681 1682 1682 1683 if ($timezone == 'gmt') { 1683 1684 1684 preg_match( '#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);1685 preg_match($regex, $date_string, $date_bits); 1685 1686 1686 1687 if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset 1687 1688 $offset = iso8601_timezone_to_offset($date_bits[7]); … … 1695 1696 return gmdate('Y-m-d H:i:s', $timestamp); 1696 1697 1697 1698 } else if ($timezone == 'user') { 1698 return preg_replace( '#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);1699 return preg_replace($regex, '$1-$2-$3 $4:$5:$6', $date_string); 1699 1700 } 1700 1701 } 1701 1702