--- event.module.orig	2003-12-16 01:00:33.000000000 -0800
+++ event.module	2004-04-04 15:40:58.000000000 -0700
@@ -97,7 +97,7 @@
 
   $timestamp = gmmktime(0, 0, 0, $month, $day, $year);
   $breadcrumbs[] = l($year, "event/$year");
-  $breadcrumbs[] = l(format_date($timestamp, 'custom', 'F'), "event/$year/$month");
+  $breadcrumbs[] = l(event_format_date($timestamp, 'custom', 'F'), "event/$year/$month");
   print theme('header');
   print theme('breadcrumb', $breadcrumbs);
   print theme('box', t('Events'), $output);
@@ -116,7 +116,7 @@
           $links[] = l(t('edit event'), "node/edit/$node->nid", array('title' => t('Edit this event.')));
         }
         else {
-          $links[] = l(t('calendar'), 'event/'. format_date($node->start, 'custom', 'Y/m/d'));
+          $links[] = l(t('calendar'), 'event/'. event_format_date($node->start, 'custom', 'Y/m/d'));
         }
       }
       break;
@@ -131,7 +131,7 @@
       }
       if (user_access('access content')) {
         menu('event', t('events'), 'page', 1);
-        menu('event/'. format_date(time(), 'custom', 'Y/m/d'), t('calendar'), 'page');
+        menu('event/'. event_format_date(time(), 'custom', 'Y/m/d'), t('calendar'), 'page');
         menu('event/search', t('search'), 'page', 1);
       }
   }
@@ -190,7 +190,7 @@
 
   $output = '<div class="event">';
   $output .= '<div class="details">';
-  $output .= form_item(t('Start'), format_date($node->start));
+  $output .= form_item(t('Start'), event_format_date($node->start));
   foreach ($fields as $field => $def) {
     if ($node->$field) {
       if ($def[0] == "select") {
@@ -240,11 +240,11 @@
 
   if ($timestamp) {
     // Use format_date(), it handles user timezone and locale.
-    $year = format_date($timestamp, 'custom', 'Y');
-    $month = format_date($timestamp, 'custom', 'm');
-    $day = format_date($timestamp, 'custom', 'd');
-    $hour = format_date($timestamp, 'custom', 'H');
-    $minute = format_date($timestamp, 'custom', 'i');
+    $year = event_format_date($timestamp, 'custom', 'Y');
+    $month = event_format_date($timestamp, 'custom', 'm');
+    $day = event_format_date($timestamp, 'custom', 'd');
+    $hour = event_format_date($timestamp, 'custom', 'H');
+    $minute = event_format_date($timestamp, 'custom', 'i');
   }
 
   $when = '<div class="container-inline">';
@@ -375,7 +375,7 @@
     $result = db_query("SELECT n.nid FROM {event} e INNER JOIN {node} n USING (nid) WHERE n.status = 1 AND e.start > %d AND e.start < %d ORDER BY start", $first, $last);
     while ($node = db_fetch_object($result)) {
       $node = node_load($node);
-      $data[$year][$month][format_date($node->start, 'custom', 'j')][] = $node;
+      $data[$year][$month][event_format_date($node->start, 'custom', 'j')][] = $node;
     }
   }
 
@@ -392,7 +392,7 @@
   if (count($data = event_calendar_data($year, $month, $day))) {
     foreach ($data as $node) {
       $output .= '<div class="event">';
-      $output .= '<span class="time">'. format_date($node->start, 'custom', 'H:i') .'</span>';
+      $output .= '<span class="time">'. event_format_date($node->start, 'custom', 'H:i') .'</span>';
       $output .= '<span class="title">'. l($node->title, "node/view/$node->nid") .'</span>';
       foreach ($fields as $field => $def) {
         if ($def[4] && $node->$field) {
@@ -636,4 +636,38 @@
 }
 
 
+function event_format_date($timestamp, $type = "medium", $format = "") {
+  global $user;
+
+  $timestamp += $user->timezone;
+
+  switch ($type) {
+    case "small":
+      $format = variable_get("date_format_short", "m/d/Y - H:i");
+      break;
+    case "large":
+      $format = variable_get("date_format_long", "l, F j, Y - H:i");
+      break;
+    case "custom":
+      // No change to format
+      break;
+    case "medium":
+    default:
+      $format = variable_get("date_format_medium", "D, m/d/Y - H:i");
+  }
+
+  for ($i = strlen($format); $i >= 0; $c = $format[--$i]) {
+    if (strstr("DFlMSw", $c)) {
+      $date = t(gmdate($c, $timestamp)) . $date;
+    }
+    else if (strstr("AaBdgGhHiIjLmnOrstTUWYyZz", $c)) {
+      $date = gmdate($c, $timestamp) . $date;
+    }
+    else {
+      $date = $c.$date;
+    }
+  }
+  return $date;
+}
+
 ?>
