Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.925 diff -u -r1.925 common.inc --- includes/common.inc 18 Jun 2009 21:19:01 -0000 1.925 +++ includes/common.inc 25 Jun 2009 14:25:54 -0000 @@ -1909,38 +1909,43 @@ $format = variable_get('date_format_medium', 'D, m/d/Y - H:i'); } - $max = strlen($format); - $date = ''; // Create a DateTime object from the timestamp. $date_time = date_create('@' . $timestamp); // Set the time zone for the DateTime object. date_timezone_set($date_time, $timezones[$timezone]); - for ($i = 0; $i < $max; $i++) { - $c = $format[$i]; - if (strpos('AaeDlMT', $c) !== FALSE) { - $date .= t(date_format($date_time, $c), array(), array('langcode' => $langcode)); - } - elseif ($c == 'F') { - // Special treatment for long month names: May is both an abbreviation - // and a full month name in English, but other languages have - // different abbreviations. - $date .= t(date_format($date_time, $c), array(), array('context' => 'Long month name', 'langcode' => $langcode)); - } - elseif (strpos('BcdGgHhIijLmNnOoPSstUuWwYyZz', $c) !== FALSE) { - $date .= date_format($date_time, $c); - } - elseif ($c == 'r') { - $date .= format_date($timestamp, 'custom', 'D, d M Y H:i:s O', $timezone, $langcode); - } - elseif ($c == '\\') { - $date .= $format[++$i]; - } - else { - $date .= $c; + // Replace characters in format string which need to be translated, 'X', with + // an arbitrary escape sequence '+=X=+'. The 'F' format character, long month + // name, requires special handling (see below). These patterns exclude any + // format characters which have been escaped with '\' (octal 134). + $format = preg_replace(array('@(? $match) { + $replace_from[] = "+=$match=+"; + if ($match == 'F') { + // Special treatment for long month names: May is both an abbreviation + // and a full month name in English, but other languages have + // different abbreviations. + $replace_to[] = t($replacements[$index], array(), array('context' => 'Long month name', 'langcode' => $langcode)); + } + else { + $replace_to[] = t($replacements[$index], array(), array('langcode' => $langcode)); + } } } + $date = str_replace($replace_from, $replace_to, $format); + return $date; }