--- includes/calendar.inc       2009-11-06 07:43:39.000000000 -0700
+++ includes/calendar.inc.patched       2009-11-06 09:46:32.000000000 -0700
@@ -516,16 +516,46 @@ function calendar_build_nodes(&$view, &$
           }

           // Make date objects
+          // Get fields settings so you can determine all_day based on granularity
+          $global_settings = db_result(db_query("SELECT global_settings FROM {content_node_field} WHERE field_name = '%s'", $real_field));
+          $widget_settings = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s' AND type_name = '%s'", $real_field, $node->node_type));
+          $global_settings = unserialize($global_settings);
+          $widget_settings = unserialize($widget_settings);
+          $increment = $widget_settings['increment'];
+          $max_seconds = array_pop(date_seconds('s', TRUE, $increment));
+          $max_minutes = array_pop(date_minutes('i', TRUE, $increment));
+          // we need two times because calendar cuts multi-day events into daily chunks that end at 23:59:59
+          // but we may have just a day long all-day event that ends at the granularity and increment specified
+          // in the content type.
+          $max_time = ''; // multi-day end time
+          $max_time2 = '';// granularity end time
+          $format = '';
+          if (isset($global_settings['granularity']['hour'])) {
+            $max_time .= '23';
+            $max_time2 .= '23';
+            $format .= 'H';
+          }
+          if (isset($global_settings['granularity']['minute'])) {
+            $max_time .= $max_time ? ':' . $max_minutes : $max_minutes;
+            $max_time2 .= $max_time2 ? ':' . '59' : '59';
+            $format .= $max_format ? ':i' : 'i';
+          }
+          if (isset($global_settings['granularity']['second'])) {
+            $max_time .= $max_time ? ':' . $max_seconds : $max_seconds;
+            $max_time2 .= $max_time2 ? ':' . '59' : '59';
+            $format .= $max_format ? ':s' : 's';
+          }
           $node->calendar_start_date = date_create($node->calendar_start, timezone_open($to_zone));
           $node->calendar_end_date = date_create($node->calendar_end, timezone_open($to_zone));
           if (date_format($node->calendar_start_date, 'H:i:s') == '00:00:00' &&
-            date_format($node->calendar_end_date, 'H:i:s') == '23:59:59') {
+            ( date_format($node->calendar_end_date, 'H:i:s') == '00:00:00' ||
+              date_format($node->calendar_end_date, $format) == $max_time ||
+              date_format($node->calendar_end_date, $format) == $max_time2 ) ) {
             $node->calendar_all_day = TRUE;
           }
           else {
             $node->calendar_all_day = FALSE;
           }
-
           // Flag all day values specifically set in date.
           $all_day_field = str_replace(array('_value2', '_value'), '_all_day', $node->datefield);
           if (!empty($all_day_field) && !empty($item->$all_day_field)) {
