diff --git a/date_facets.module b/date_facets.module index d666822..9ac3f15 100755 --- a/date_facets.module +++ b/date_facets.module @@ -216,24 +216,37 @@ class date_facet_category extends cck_facet_category { * implementor is responsible to ensure adequate security filtering. */ function get_label($html = FALSE) { + + // Initialize date components + $y = 0; + $m = 1; + $d = 1; + + // Set format. if (isset($this->_value['day'])) { - // Format date with YYYY-MM-DD. - $timestamp = gmmktime(0, 0, 0, (int)$this->_value['month'], (int)$this->_value['day'], (int)$this->_value['year']); $format = variable_get('date_facets_format_ymd', 'm/d/Y'); + $d =$this->_value['day']; } elseif (isset($this->_value['month'])) { - // Format date with YYYY-MM. - $timestamp = gmmktime(0, 0, 0, (int)$this->_value['month'], 1, (int)$this->_value['year']); $format = variable_get('date_facets_format_ym', 'm/Y'); + $m = $this->_value['month']; } elseif (isset($this->_value['year'])) { - // Format date with YYYY. - $timestamp = gmmktime(0, 0, 0, 1, 1, (int)$this->_value['year']); $format = variable_get('date_facets_format_y', 'Y'); + $y = $this->_value['year']; } - if ($timestamp) { - return format_date($timestamp, 'custom', $format, 0); + + // Make ISO 8601 date string. + $date_string = sprintf("%04d-%02d-%02dT00:00:00+00:00",$y, $m, $d); + + // Make date via Date API. + $date_obj = date_make_date($date_string); + + // Return formatted label. + if($date_obj){ + return date_format_date($date_obj, 'custom', $format); } + } /**