diff --git a/sites/all/modules/date/date_api/date_api.module b/sites/all/modules/date/date_api/date_api.module
index d85a8a5..b13af4c 100644
--- a/sites/all/modules/date/date_api/date_api.module
+++ b/sites/all/modules/date/date_api/date_api.module
@@ -500,7 +500,7 @@ class DateObject extends DateTime {
    */
   public function limitGranularity($granularity) {
     foreach ($this->granularity as $key => $val) {
-      if ($val != 'timezone' && !in_array($val, $granularity)) {
+      if ($val != 'timezone' && !in_array($val, $granularity, TRUE)) {
         unset($this->granularity[$key]);
       }
     }
diff --git a/sites/all/modules/date/tests/date_api.test b/sites/all/modules/date/tests/date_api.test
index f50020c..9ebb2e9 100644
--- a/sites/all/modules/date/tests/date_api.test
+++ b/sites/all/modules/date/tests/date_api.test
@@ -363,6 +363,23 @@ class DateAPITestCase extends DrupalWebTestCase {
     $expected = '10:30:00';
     $this->assertEqual($expected, $value, "Test new dateObject($input, $timezone, $format): should be $expected, found $value.");
 
+		// Check that empty granularity parts don't break the limit.
+		$input = '2011-06-11 16:03:10';
+		$timezone = 'UTC';
+		$format = 'Y-m-d H:i:s';
+		$date = new dateObject($input, $timezone, $format);
+		$date->limitGranularity(array(
+			'year' => 'year',
+			'month' => 'month',
+			'day' => 0,
+			'hour' => 'hour',
+			'minute' => 0,
+			'second' => 0,
+		));
+		$value = $date->format('Y-m-d H:i:s');
+		$expected = '2011-06 16';
+		$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone, $format) with granularity limited to year, month and hour: should be $expected, found $value.");
+
     // Test date ranges.
     $valid = array(
       '-20:+20',
