? sites/default/files
? sites/default/settings.php
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.907
diff -u -p -r1.907 common.inc
--- includes/common.inc	21 May 2009 21:12:22 -0000	1.907
+++ includes/common.inc	22 May 2009 00:03:29 -0000
@@ -1576,35 +1576,30 @@ 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(), $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 .= trim(t('!long-month-name ' . date_format($date_time, $c), array('!long-month-name' => ''), $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
+  // escape sequence '+=X=+'. The 'F' format character requires special handling
+  // because May is both an abbreviation and month name in English, while other
+  // languages have different abbreviations. 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) == '!') {
+        $date = str_replace("+=$match=+", t(str_replace('!', '!long-month-name ', $match), array('!long-month-name ' => ''), $langcode), $date);
+      }
+      else {
+        $date = str_replace("+=$match=+", t($match, array(), $langcode), $date);
+      }
     }
   }
 
