### Eclipse Workspace Patch 1.0
#P chokladorama
Index: sites/all/modules/apachesolr/apachesolr.module
===================================================================
--- sites/all/modules/apachesolr/apachesolr.module	(revision 140)
+++ sites/all/modules/apachesolr/apachesolr.module	(working copy)
@@ -841,19 +841,14 @@
   // our callers always have field information handy.
   $unix = strtotime($iso);
   if ($unix > 0) {
-    switch ($gap) {
-      case 'YEAR':
-        return gmdate('Y', $unix);
-      case 'MONTH':
-        return gmdate('F Y', $unix);
-      case 'DAY':
-        return gmdate('F j, Y', $unix);
-      case 'HOUR':
-        return gmdate('g A', $unix);
-      case 'MINUTE':
-        return gmdate('g:i A', $unix);
-      case 'SECOND':
-        return gmdate('g:i:s A', $unix);
+    $date_format = apachesolr_get_facet_created_date_format($gap);
+     
+    if(module_exists('date_api')) {
+      global $language;
+      $date = date_make_date($iso); 
+      return date_format_date($date, 'custom', $date_format, $language->language);
+    } else {
+      return gmdate($date_format, $unix);
     }
   }
 
@@ -942,6 +937,7 @@
   $limits = variable_get('apachesolr_facet_query_limits', array());
   $facet_missing = variable_get('apachesolr_facet_missing', array());
 
+
   $limit = drupal_map_assoc(array(50, 40, 30, 20, 15, 10, 5, 3));
 
   $form['apachesolr_facet_query_initial_limit'] = array(
@@ -966,6 +962,27 @@
     '#description' => t('A facet can be generated corresponding to all documents entirely missing this field.'),
     '#default_value' => isset($facet_missing[$module][$delta]) ? $facet_missing[$module][$delta] : 0,
   );
+  
+  if($delta == "created") {
+     $gaps = array('YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND'); 
+
+     $form['apachesolr_facet_created_date_format'] = array(
+      '#type' => 'fieldset',
+      '#title' => 'Date display formats',
+      '#collapsible' => TRUE,
+      '#description' => t('See the <a href="@url">PHP manual</a> for available options.',array('@url' => 'http://php.net/manual/function.date.php')),
+    ); 
+  
+    foreach($gaps as $gap) {
+      $form['apachesolr_facet_created_date_format']['apachesolr_facet_created_date_format_'.$gap] = array(
+        '#type' => 'textfield',
+        '#title' => $gap,
+        '#description' => '',
+        '#default_value' => apachesolr_get_facet_created_date_format($gap),
+      );
+    } 
+  }
+
   return $form;
 }
 
@@ -986,6 +1003,12 @@
   $facet_missing = variable_get('apachesolr_facet_missing', array());
   $facet_missing[$module][$delta] = (int)$edit['apachesolr_facet_missing'];
   variable_set('apachesolr_facet_missing', $facet_missing);
+  // Created date formats
+  foreach($edit as $index => $value) {
+    if(strpos($index,'apachesolr_facet_created_date_format_') !== FALSE) {
+      variable_set($index, $value);
+    }
+  }
 }
 
 /**
@@ -1463,6 +1486,28 @@
 }
 
 /**
+ * Get facet created display format
+ * @param $gap 
+ * @return date format string
+ */
+function apachesolr_get_facet_created_date_format($gap) {
+  switch ($gap) {
+    case 'YEAR':
+      return variable_get('apachesolr_facet_created_date_format_'.$gap, 'Y');
+    case 'MONTH':
+      return variable_get('apachesolr_facet_created_date_format_'.$gap, 'F Y');
+    case 'DAY':
+      return variable_get('apachesolr_facet_created_date_format_'.$gap, 'F j, Y');
+    case 'HOUR':
+      return variable_get('apachesolr_facet_created_date_format_'.$gap, 'g A');
+    case 'MINUTE':
+      return variable_get('apachesolr_facet_created_date_format_'.$gap, 'g:i A');
+    case 'SECOND':
+      return variable_get('apachesolr_facet_created_date_format_'.$gap, 'g:i:s A');
+  }
+}
+
+/**
  * The interface for all 'query' objects.
  */
 interface Drupal_Solr_Query_Interface {
