? sites/default/files
? sites/default/settings.php
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.925
diff -u -p -r1.925 common.inc
--- includes/common.inc	18 Jun 2009 21:19:01 -0000	1.925
+++ includes/common.inc	25 Jun 2009 17:22:35 -0000
@@ -1909,36 +1909,34 @@ function format_date($timestamp, $type =
       $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('@(?<!\134)r@', '@(?<!\134)F@', '@(?<!\134)([AaeDlMT])@'), array('D, d M Y H:i:s O', '+=!F=+', '+=$1=+'), $format);
+
+  // Make a single call to date_format() using the format string.
+  $date = date_format($date_time, $format);
+
+  // Now look for any escape sequences and translate them.
+  if (preg_match_all('@\+=([a-zA-Z/_!-]*)=\+@', $date, $matches)) {
+    foreach ($matches[1] as $match) {
+      if (substr($match, 0, 1) == '!') {
+        // 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[] = t(substr($match, 1), array(), array('context' => 'Long month name', 'langcode' => $langcode));
+      }
+      else {
+        $replace[] = t($match, array(), array('langcode' => $langcode));
+      }
     }
+    $date = str_replace($matches[0], $replace, $date);
   }
 
   return $date;
