Index: date_facets.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/cck_facets/date_facets.module,v
retrieving revision 1.8
diff -u -r1.8 date_facets.module
--- date_facets.module	4 Jan 2009 20:06:55 -0000	1.8
+++ date_facets.module	13 Mar 2009 19:34:00 -0000
@@ -15,7 +15,7 @@
  * Implementation of hook_cck_facets_collect().
  */
 function date_facets_cck_facets_collect(&$facets, $field, $domain, $env, $arg = NULL) {
-  if ($field['type'] == 'date' || $field['type'] == 'datestamp') {
+  if ($field['type'] == 'date' || $field['type'] == 'datestamp' || $field['type'] == 'datetime' ) {
     $facet_class = $field['type'] .'_facet';
     $category_class = $field['type'] .'_facet_category';
   
@@ -85,6 +85,16 @@
               $facets[] = new datestamp_facet($field, $active_path);
             }
           }
+          elseif ($field['type'] == 'datetime') {
+            // Iterate through the field's multiple values.
+            foreach ($arg->{$field['field_name']} as $item) {
+              $date = array_shift($item); // Take the item's main column.
+              print_r( $date );
+
+              // fix!!! do something!
+            }
+          }
+
         }
         break;
     }
@@ -472,6 +482,70 @@
   }
 }
 
+
+/**
+ * A facet for Datetime fields.
+ *
+ * @see datetime_facet_category
+ */
+class datetime_facet extends date_facet {
+  /**
+   * Constructor. 
+   *
+   * @param $field
+   *   The field corresponding to this facet.
+   * @param $active_path
+   *   Array representing the path leading to the active category, including the
+   *   active category itself. Defaults to an empty array, meaning no active
+   *   category.
+   */
+  function datetime_facet($field, $active_path = array()) {
+    parent::date_facet($field, $active_path);
+  }
+
+  /**
+   * This factory method creates categories given query results that include the
+   * fields selected in get_root_categories_query() or get_subcategories_query().
+   *
+   * @param $results
+   *   $results A database query result resource.
+   *
+   * @return
+   *   Array of categories.
+   */
+  function build_categories($results) {
+    $categories = array();
+    while ($result = db_fetch_object($results)) {
+      $categories[] = new datetime_facet_category($this->_field, $result->{$this->_field['field_name'] .'_year'}, $result->{$this->_field['field_name'] .'_month'}, $result->{$this->_field['field_name'] .'_day'}, $result->count);
+    }
+    return $categories;
+  }
+}
+
+/**
+ * A facet category for Datetime fields. 
+ */
+class datetime_facet_category extends date_facet_category {
+  
+  /**
+   * Constructs a category for the specified date.
+   *
+   * @param $year
+   *   Year corresponding to this category.
+   * @param $month
+   *   Month corresponding to this category. Optional, but must be specified if
+   *   $day is specified.
+   * @param $day
+   *   Day corresponding to this category. Optional.
+   * @param $count
+   *   The number of nodes associated to this category within the current
+   *   search. Optional.
+   */
+  function datetime_facet_category($field, $year, $month = NULL, $day = NULL, $count = NULL) {
+    parent::date_facet_category($field, $year, $month, $day, $count);
+  }
+}
+
 /**
  * Checks the validity of a date or partial date.
  */
