Make WordPress Core

Ticket #7651: 7651.r8781.diff

File 7651.r8781.diff, 1.5 KB (added by jacobsantos, 16 years ago)

Convert constants to lowercase strings and compare. Based off of r8781

  • formatting.php

     
    12081208/**
    12091209 * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
    12101210 *
    1211  * {@internal Missing Long Description}}
    1212  *
    12131211 * @since 1.5.0
    12141212 *
    12151213 * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.
    1216  * @param unknown_type $timezone Optional. If set to GMT returns the time minus gmt_offset. Default USER.
     1214 * @param unknown_type $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
    12171215 * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
    12181216 */
    1219 function iso8601_to_datetime($date_string, $timezone = USER) {
    1220         if ($timezone == GMT) {
     1217function iso8601_to_datetime($date_string, $timezone = 'user') {
     1218        $timezone = strtolower($timezone);
    12211219
     1220        if ($timezone == 'gmt') {
     1221
    12221222                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);
    12231223
    12241224                if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
     
    12321232
    12331233                return gmdate('Y-m-d H:i:s', $timestamp);
    12341234
    1235         } else if ($timezone == USER) {
     1235        } else if ($timezone == 'user') {
    12361236                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);
    12371237        }
    12381238}