Make WordPress Core

Ticket #2774: 2774b.diff

File 2774b.diff, 3.8 KB (added by mdawaffe, 18 years ago)

Hit only the first number. mysql2date and date_i18n

  • wp-includes/functions-formatting.php

     
    521521
    522522function zeroise($number,$threshold) { // function to add leading zeros when necessary
    523523        return sprintf('%0'.$threshold.'s', $number);
    524         }
     524}
    525525
    526526
    527527function backslashit($string) {
     528        $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
    528529        $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
    529530        return $string;
    530531}
  • wp-includes/functions.php

     
    3737                $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
    3838                $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
    3939                $dateformatstring = ' '.$dateformatstring;
    40                 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
    41                 $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
    42                 $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
    43                 $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
    44                 $dateformatstring = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring);
    45                 $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring);
     40                $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     41                $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
     42                $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
     43                $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
     44                $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring);
     45                $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring);
    4646
    4747                $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    4848        }
     
    8080                $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
    8181                $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
    8282                $dateformatstring = ' '.$dateformatstring;
    83                 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
    84                 $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
    85                 $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
    86                 $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
    87                 $dateformatstring = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring);
    88                 $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring);
     83                $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     84                $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
     85                $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
     86                $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
     87                $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring);
     88                $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring);
    8989
    9090                $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    9191        }