diff --git a/facetapi.date.inc b/facetapi.date.inc
index 28d6e29..fa0f5ab 100644
--- a/facetapi.date.inc
+++ b/facetapi.date.inc
@@ -94,37 +94,54 @@ function facetapi_get_next_date_gap($gap, $min_gap = FACETAPI_DATE_SECOND) {
  * This function uses Unix timestamps for its computation and so is not useful
  * for dates outside that range.
  *
- * @param $start_date
+ * @param int $start_time
  *   A string containing the start date as an ISO date string.
- * @param $end_date
+ * @param int $end_time
  *   A string containing the end date as an ISO date string.
+ * @param string|NULL $min_gap
+ *   (Optional) The minimum gap that should be returned.
  *
- * @return
+ * @return string
  *   A string containing the gap, see FACETAPI_DATE_* constants for valid
  *   values. Returns FALSE of either of the dates cannot be converted to a
  *   timestamp.
  */
-function facetapi_get_timestamp_gap($start_time, $end_time) {
+function facetapi_get_timestamp_gap($start_time, $end_time, $min_gap = NULL) {
   $time_diff = $end_time - $start_time;
   switch (TRUE) {
     // NOTE: 31536000 == 60 * 60 * 24 * 365
     case ($time_diff >= 31536000):
-      return FACETAPI_DATE_YEAR;
+      $gap = FACETAPI_DATE_YEAR;
+      break;
 
     case ($time_diff >= 86400 * gmdate('t', $start_time)):
-      return FACETAPI_DATE_MONTH;
+      $gap = FACETAPI_DATE_MONTH;
+      break;
 
     case ($time_diff >= 86400):
-      return FACETAPI_DATE_DAY;
+      $gap = FACETAPI_DATE_DAY;
+      break;
 
     case ($time_diff >= 3600):
-      return FACETAPI_DATE_HOUR;
+      $gap = FACETAPI_DATE_HOUR;
+      break;
 
     case ($time_diff >= 60):
-      return FACETAPI_DATE_MINUTE;
+      $gap = FACETAPI_DATE_MINUTE;
+      break;
 
     default:
-      return FACETAPI_DATE_SECOND;
+      $gap = FACETAPI_DATE_SECOND;
+      break;
+  }
+
+  // Return the calculated gap if a minimum gap was not passed of the calculated
+  // gap is a larger interval than the minimum gap.
+  if (null === $min_gap || facetapi_gap_compare($gap, $min_gap) >= 0) {
+    return $gap;
+  }
+  else {
+    return $min_gap;
   }
 }
 
@@ -136,18 +153,20 @@ function facetapi_get_timestamp_gap($start_time, $end_time) {
  *   A string containing the start date as an ISO date string.
  * @param $end_date
  *   A string containing the end date as an ISO date string.
+ * @param string|NULL $min_gap
+ *   (Optional) The minimum gap that should be returned.
  *
- * @return
+ * @return string
  *   A string containing the gap, see FACETAPI_DATE_* constants for valid
  *   values. Returns FALSE of either of the dates cannot be converted to a
  *   timestamp.
  *
  * @see facetapi_get_timestamp_gap()
  */
-function facetapi_get_date_gap($start_date, $end_date) {
+function facetapi_get_date_gap($start_date, $end_date, $min_gap = NULL) {
   $range = array(strtotime($start_date), strtotime($end_date));
   if (!in_array(FALSE, $range, TRUE)) {
-    return facetapi_get_timestamp_gap($range[0], $range[1]);
+    return facetapi_get_timestamp_gap($range[0], $range[1], $min_gap);
   }
   return FALSE;
 }
@@ -258,3 +277,35 @@ function facetapi_get_next_date_increment($date, $gap) {
   }
   return FALSE;
 }
+
+/**
+ * Compares two timestamp gaps.
+ *
+ * @param string $gap1
+ * @param string $gap2
+ *
+ * @return int
+ *   Returns -1 if gap1 is less than gap2, 1 if gap1 is greater than gap2, and 0
+ *   if they are equal.
+ */
+function facetapi_gap_compare($gap1, $gap2) {
+
+  $gap_numbers = array(
+    FACETAPI_DATE_YEAR => 6,
+    FACETAPI_DATE_MONTH => 5,
+    FACETAPI_DATE_DAY => 4,
+    FACETAPI_DATE_HOUR => 3,
+    FACETAPI_DATE_MINUTE => 2,
+    FACETAPI_DATE_SECOND => 1,
+  );
+
+  $gap1_num = isset($gap_numbers[$gap1]) ? $gap_numbers[$gap1] : 6;
+  $gap2_num = isset($gap_numbers[$gap2]) ? $gap_numbers[$gap2] : 6;
+
+  if ($gap1_num == $gap2_num) {
+    return 0;
+  }
+  else {
+    return ($gap1_num < $gap2_num) ? -1 : 1;
+  }
+}
