Index: calendar.css
===================================================================
RCS file: calendar/calendar.css,v
retrieving revision 1.30.2.23
diff -u -p -r1.30.2.23 calendar.css
--- calendar.css	14 Feb 2009 20:07:59 -0000	1.30.2.23
+++ calendar.css	24 Sep 2010 07:21:56 -0000
@@ -369,4 +369,80 @@ table.calendar-legend tr.even .stripe {
 .calendar-calendar td.past {}
 .calendar-calendar td.future {}
 .calendar-calendar td.has-events {}
-.calendar-calendar td.has-no-events {}
\ No newline at end of file
+.calendar-calendar td.has-no-events {}
+
+/* Multi day styles */
+.calendar-calendar td.date-box { 
+  height : 1%;
+  border-bottom: 0px;
+  padding-bottom : 2px;
+}
+
+.calendar-calendar td.date-box .inner { 
+  min-height : inherit;
+}
+
+.calendar-calendar td.multi-day { 
+  height : 1%;
+  border-top: 0px;
+  border-bottom: 0px;
+}
+
+.calendar-calendar td.single-day { 
+  height : 98%;
+  border-top: 0px;
+}
+.calendar-calendar td.multi-day .inner, 
+.calendar-calendar td.single-day .inner { 
+	  min-height : inherit;
+	  width : 100%;
+}
+
+.calendar-calendar td.single-day.no-entry,
+.calendar-calendar td.single-day .calendar-empty {
+	height : 100%;
+  line-height : 100%;
+  font-size : 100%;
+  min-height : 5em;
+}
+
+.calendar-calendar td.single-day .calendar-empty,
+.calendar-calendar td.single-day.empty,
+.calendar-calendar td.date-box.empty {
+  background : #F4F4F4;
+}
+
+.calendar-calendar td.single-day .inner div, 
+.calendar-calendar td.single-day .inner div a ,
+.calendar-calendar td.multi-day .inner div, 
+.calendar-calendar td.multi-day .inner div a ,
+.calendar-calendar td .inner div.calendar.monthview div, 
+.calendar-calendar td .inner div.calendar.monthview div a {
+	background : none;
+}
+
+.calendar-calendar .calendar.monthview {
+  -moz-border-radius : 5px;
+  border-radius : 5px;
+  height : 100%;
+  float : none;
+  display : block;
+  margin : .25em auto;
+}
+
+
+.calendar-calendar td.single-day .calendar.monthview {
+  background : #FFD8C0;
+  width : 95%;
+}
+
+.calendar-calendar td.multi-day .calendar.monthview {
+  background : #E3E9FF;
+  width : 98%;
+  height : 2em;
+  overflow : hidden;
+}
+
+.calendar-calendar td.multi-day .calendar.monthview .view-field {
+  display:inline;
+}
Index: calendar.module
===================================================================
RCS file: calendar/calendar.module,v
retrieving revision 1.121.2.38
diff -u -p -r1.121.2.38 calendar.module
--- calendar.module	17 Mar 2009 18:03:36 -0000	1.121.2.38
+++ calendar.module	24 Sep 2010 07:21:57 -0000
@@ -92,8 +92,16 @@ function calendar_theme() {
       ),
     'calendar_time_row_heading' => $base + array(
       'arguments' => array('start_time', 'next_start_time', 'curday_date'),
+      ),
+    'calendar_month_col' => $base + array(
+      'template' => 'calendar-month-col',
+      'arguments' => array('item' => NULL),
       ),  
-    );
+    'calendar_month_row' => $base + array(
+      'template' => 'calendar-month-row',
+      'arguments' => array('inner' => NULL),
+      ),  
+   );
 }
 
 /**
Index: includes/calendar.inc
===================================================================
RCS file: calendar/includes/calendar.inc,v
retrieving revision 1.1.2.40
diff -u -p -r1.1.2.40 calendar.inc
--- includes/calendar.inc	11 May 2009 22:24:27 -0000	1.1.2.40
+++ includes/calendar.inc	24 Sep 2010 07:21:58 -0000
@@ -32,7 +32,7 @@ function calendar_build_calendar($view, 
       $rows = array();
       $view->date_info->mini = TRUE;
       for ($i = 1; $i <= 12; $i++) {
-        $rows[$i] = calendar_build_month($curday, $view, $items);
+        $rows[$i] = calendar_build_year_month($curday, $view, $items);
       }
       $view->date_info->mini = FALSE;
       break;
@@ -59,7 +59,7 @@ function calendar_build_calendar($view, 
 /**
  * Build one month.
  */
-function calendar_build_month(&$curday, $view, $items) {
+function calendar_build_year_month(&$curday, $view, $items) {
   $month = date_format($curday, 'n');
   date_modify($curday, '-' . strval(date_format($curday, 'j')-1) . ' days');
 
@@ -76,6 +76,25 @@ function calendar_build_month(&$curday, 
 }
 
 /**
+ * Build one month.
+ */
+function calendar_build_month(&$curday, $view, $items) {
+  $month = date_format($curday, 'n');
+  date_modify($curday, '-' . strval(date_format($curday, 'j')-1) . ' days');
+
+  $rows = array();
+  do {
+    $rows = array_merge($rows, calendar_build_month_week($curday, $view, $items, TRUE));
+    $curday_date = date_format($curday, DATE_FORMAT_DATE);
+    $curday_month = date_format($curday, 'n');
+  } while ($curday_month == $month && $curday_date <= $view->date_info->max_date_date);
+
+  // Merge the day names in as the first row.
+  $rows = array_merge(array(calendar_week_header($view)), $rows);
+  return $rows;
+}
+
+/**
  * Build one week row.
  */
 function calendar_build_week(&$curday, $view, $items, $check_month = FALSE) {
@@ -139,8 +158,278 @@ function calendar_build_week(&$curday, $
 }
 
 /**
+ * Build one week row.
+ */
+function calendar_build_month_week(&$curday, $view, $items, $check_month = FALSE) {
+  $init_day = clone($curday);
+  $curday_date = date_format($curday, DATE_FORMAT_DATE);
+  $weekdays = calendar_untranslated_days($items, $view);
+  $today = date_format(date_now(date_default_timezone_name()), DATE_FORMAT_DATE);
+  $month = date_format($curday, 'n');
+  $week = date_week($curday_date);
+  $first_day = variable_get('date_first_day', 0);
+  
+  // Set up buckets
+  $total_rows = 0;
+  $multiday_buckets = array( array(), array(), array(), array(), array(), array(), array());
+  $singleday_buckets = array( array(), array(), array(), array(), array(), array(), array());
+  
+  // move backwards to the first day of the week
+  $day_wday = date_format($curday, 'w');
+  date_modify($curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
+  $curday_date = date_format($curday, DATE_FORMAT_DATE);
+    
+  for ($i = 0; $i < 7; $i++) {
+    if ($check_month && ($curday_date < $view->date_info->min_date_date || $curday_date > $view->date_info->max_date_date || date_format($curday, 'n') != $month)) {
+      $class = strtolower($weekdays[$i] . ($view->date_info->mini ? ' mini' : '')) .' empty';
+      $singleday_buckets[$i][] = theme('calendar_empty_day', $curday_date, $view); 
+    }
+    else {
+      calendar_build_month_day($curday, $view, $items, $i, $multiday_buckets, $singleday_buckets);
+    }
+    $multiday_buckets[$i] = array_values($multiday_buckets[$i]);
+    $total_rows = max(count($multiday_buckets[$i]) + 1, $total_rows);
+    date_modify($curday, '+1 day');
+    $curday_date = date_format($curday, DATE_FORMAT_DATE); 
+  }
+  
+  // Theme each row
+  $output = "";
+  $final_day = clone($curday);
+
+  // Add a row for the day numbers
+  for( $i = 0; $i < $total_rows + 1; $i++ ) {
+    $inner = "";
+    
+    // If we're displaying the week number, add it as the
+    // first cell in the week.
+    if ( $i == 0 && !empty($view->date_info->style_with_weekno) && !in_array($view->date_info->granularity, array('day', 'week'))) {
+      $url = $view->get_path() .'/'. $view->date_info->year .'-W'. $week;
+      if (!empty($view->date_info->display_types['week'])) {
+        $weekno = l($week, $url, array('query' => !empty($view->date_info->append) ? $view->date_info->append : ''));
+      }
+      else { 
+        // Do not link week numbers, if Week views are disabled.
+        $weekno = $week;
+      }
+      $item = array (
+        'entry' => $weekno,
+        'colspan' => 1,
+        'rowspan' => $total_rows + 1,
+        'id' => $view->name . '-weekno-' . $curday_date,  
+        'class' => 'week'
+      );
+      $inner .= theme('calendar_month_col',$item);
+    }
+    
+    $curday = clone($init_day);
+
+    // move backwards to the first day of the week
+    $day_wday = date_format($curday, 'w');
+    date_modify($curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
+    
+    for ( $wday = 0; $wday < 7; $wday++ ) {
+
+      $curday_date = date_format($curday, DATE_FORMAT_DATE); 
+      $class = strtolower($weekdays[$wday] . ($view->date_info->mini ? ' mini' : ''));
+      $item = NULL;
+      
+      // Add the datebox
+      if ( $i == 0 ) {
+        $item = array (
+          'entry' => theme('calendar_datebox', $curday_date, $view),
+          'colspan' => 1,
+          'rowspan' => 1,
+          'class' => 'date-box', 
+          'id' => $view->name . '-' . $curday_date . '-date-box'
+        );
+        $item['class'] .= ($curday_date == $today ? ' today' : '') .
+        ($curday_date < $today ? ' past' : '') .
+        ($curday_date > $today ? ' future' : '');
+      } else {
+        $index = $i - 1;
+        $multi_count = count($multiday_buckets[$wday]);
+        
+        // Process multi-day buckets first
+        if( $index < $multi_count ) {
+          if ($multiday_buckets[$wday][$index]['filled']) {
+            $item = $multiday_buckets[$wday][$index];
+            $item['class'] =  'multi-day';
+          }
+          if ($multiday_buckets[$wday][$index]['avail']) {
+              $item['class'] .= ($curday_date == $today ? ' today' : '') .
+              ($curday_date < $today ? ' past' : '') .
+              ($curday_date > $today ? ' future' : '');
+          }
+        // Else, process the single day bucket - we only do this once per day
+        } elseif ( $index == $multi_count ) {
+          if ( count($singleday_buckets[$wday]) == 0 && $multi_count == 0 ) {
+            $single_days = "&nbsp;";
+            $class = 'single-day no-entry';
+          } else {
+            $single_days = "";
+            foreach( $singleday_buckets[$wday] as $day ) {
+              $single_days .= $day;
+            }
+            $class = 'single-day';
+          }
+          $item = array (
+            'entry' => $single_days,
+            'colspan' => 1,
+            'rowspan' => $total_rows - $index,
+            'class' => $class, 
+            'id' => $view->name . '-' . $curday_date
+          );
+          $item['class'] .= ($curday_date == $today ? ' today' : '') .
+          ($curday_date < $today ? ' past' : '') .
+          ($curday_date > $today ? ' future' : '');
+        }
+      }
+
+      // If we have an item to render...
+      if( $item != NULL ) {
+        if ($curday_date < $view->date_info->min_date_date || $curday_date > $view->date_info->max_date_date || date_format($curday, 'n') != $month) {
+          $item['class'] .= ' empty'; 
+        }
+        $inner .= theme('calendar_month_col',$item);
+      }
+      
+      date_modify($curday, '+1 day');
+    }
+    $output .= theme('calendar_month_row',$inner);
+  }
+  $curday = $final_day;
+  $rows[$week] = array(
+    'data' => $output,
+    'class' => $class, 
+    'id' => $view->name . '-' . $curday_date);
+  return $rows;
+}
+
+/**
  * Build the contents of a single day for the $rows results.
  */
+function calendar_build_month_day($curday, $view, $items, $wday, &$multiday_buckets, &$singleday_buckets) {
+  $curday_date = date_format($curday, DATE_FORMAT_DATE);
+  $selected = FALSE;
+  $max_events = !empty($view->date_info->style_max_items) ? $view->date_info->style_max_items : 0;
+  $types = array();
+  $all_day = array();
+  $empty = '';
+  $link = '';
+  $count = 0;
+  foreach ($items as $date => $day) {
+    if ($date == $curday_date) {
+      $count = 0;
+      $selected = TRUE;
+      ksort($day);
+      foreach ($day as $time => $hour) {
+        foreach ($hour as $key => $item) {
+          $count++;
+          $types[$item->type] = $item;
+          if (!$view->date_info->mini && ($max_events == CALENDAR_SHOW_ALL || $count <= $max_events || ($count > 0 && $max_events == CALENDAR_HIDE_ALL))) {
+            // Theme the item here unless this is a 'Day' or 'Week' view.
+            // Day and week views need to do more processing before rendering
+            // the item, so just pass them the unrendered item.
+            $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_'. $view->date_info->granularity .'_node';
+            $key = date_format($item->calendar_start_date, 'H:i:s:');
+            $key = '1:'.$key.':'.$count;
+            
+            // Parse out date part
+            $start_ydate = date_format($item->date_start,DATE_FORMAT_DATE);
+            $end_ydate = date_format($item->date_end,DATE_FORMAT_DATE);
+            $cur_ydate = date_format($curday,DATE_FORMAT_DATE);
+            
+            // Is it an all day date?
+            if ($item->calendar_all_day && $start_ydate == $end_ydate ) {
+              $all_day[] = in_array($view->date_info->calendar_type, array('day', 'week')) ? $item : theme($theme, $item, $view);
+            } else {
+              // Does this event span multi-days?
+              if ($start_ydate < $cur_ydate || $end_ydate > $cur_ydate ) {
+                // If this the first day of the week, or is the start date of the multi-day event,
+                // then record this item, otherwise skip over
+                $day_no = date_format($curday,'d');
+                if ( $wday == 0 || $start_ydate == $cur_ydate || $day_no == 1 )
+                {
+                  // Fill out the rest of the weeks buckets for this slot with empty array
+                  $start = date_make_date($cur_ydate);
+                  $end = date_make_date($end_ydate);
+                  $curday_obj = date_make_date($curday_date);
+                  $last_day = date_make_date($view->date_info->max_date_date);
+                  $days = date_difference($start, $end,'days'); 
+                  $remaining_days = min(6, date_difference($last_day,$curday_obj,'days'));
+                  $bucket_cnt = min($days, $remaining_days - $wday);
+                  
+                  // See if there is an avaiable slot
+                  $avail = false;
+                  $bucket_index = count($multiday_buckets[$wday]);
+                  for( $i = 0; $i < $bucket_index; $i++ ) {
+                    if ($multiday_buckets[$wday]['00:00:00:' . $i]['avail']) {
+                      $avail = true;
+                      for( $j = 0; $j < $bucket_cnt; $j++ ) {
+                        if ( isset($multiday_buckets[$wday+$j]['00:00:00:' . $i]['avail']) && 
+                             !$multiday_buckets[$wday+$j]['00:00:00:' . $i]['avail']) {
+                          $avail = false;
+                          break;
+                        }
+                      }
+                      if($avail) {
+                        $bucket_index = $i;
+                        $key = '00:00:00:' . $bucket_index;
+                        break;
+                      }
+                    }
+                  }
+                  
+                  // Assign the item to the available bucket
+                  $multiday_buckets[$wday][$key] = array(
+                    'colspan' => $bucket_cnt + 1,
+                    'rowspan' => 1,
+                    'filled' => true,
+                    'avail' => false,
+                    'entry' => theme($theme, $item, $view)
+                  );
+                  
+                  // Block out empty buckets for the next days in this event for this week
+                  for( $i = 0; $i < $bucket_cnt; $i++ ) {
+                    $bucket = &$multiday_buckets[$i + $wday + 1];
+                    $bucket_row_count = count($bucket);
+                    $row_diff = $bucket_index - $bucket_row_count;
+                    
+                    // Fill up the preceding buckets - these are available for future
+                    // events
+                    for ( $j = 0; $j < $row_diff; $j++ ) {
+                      $bucket['00:00:00:' . ($bucket_row_count + $j) ] = array (
+                        'entry' => '&nbsp;',
+                        'colspan' => 1,
+                        'rowspan' => 1,
+                        'filled' => true,
+                        'avail' => true
+                      );
+                    }
+                    $bucket['00:00:00:' . $bucket_index ] = array(
+                      'filled' => false, 
+                      'avail' => false
+                    );
+                  }
+                  
+                }
+              } else {
+                  // Assign to single day bucket
+                  $singleday_buckets[$wday][$key] = theme($theme, $item, $view);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  
+  // Sort the buckets
+  ksort($multiday_buckets[$wday]);
+  ksort($singleday_buckets[$wday]);
+}
+
 function calendar_build_day($curday, $view, $items) {
   $curday_date = date_format($curday, DATE_FORMAT_DATE);
   $selected = FALSE;
@@ -514,7 +803,9 @@ function calendar_build_nodes(&$view, &$
             $node->calendar_start = $values[0] < $start ? $start : $values[0];
             $node->calendar_end = !empty($values[1]) ? ($values[1] > $end ? $end : $values[1]) : $node->calendar_start;
           }
-          
+          $node->date_start = date_create($values[0], timezone_open($to_zone));
+          $node->date_end = date_create(!empty($values[1]) ? $values[1] : $values[0], timezone_open($to_zone));;
+           
           // Make date objects
           $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));


Index: theme/calendar-month.tpl.php
===================================================================
RCS file: calendar/theme/calendar-month.tpl.php,v
retrieving revision 1.6.2.3
diff -u -p -r1.6.2.3 calendar-month.tpl.php
--- theme/calendar-month.tpl.php	19 Jun 2008 22:55:56 -0000	1.6.2.3
+++ theme/calendar-month.tpl.php	24 Sep 2010 07:21:59 -0000
@@ -32,15 +32,10 @@
     </tr>
   </thead>
   <tbody>
-    <?php foreach ((array) $rows as $row): ?>
-      <tr>
-        <?php foreach ($row as $cell): ?>
-          <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
-            <?php print $cell['data']; ?>
-          </td>
-        <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
+    <?php 
+      foreach ((array) $rows as $row) {
+        print $row['data'];
+      } ?>
   </tbody>
 </table>
 </div></div>
\ No newline at end of file
Index: theme/calendar-month-col.tpl.php
===================================================================
RCS file: theme/calendar-month-col.tpl.php
diff -N theme/calendar-month-col.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ theme/calendar-month-col.tpl.php	24 Sep 2010 07:47:57 -0000
@@ -0,0 +1,12 @@
+<?php
+// $Id$ 
+/**
+ * @file
+ * Template to display a column
+ */
+?>
+<td id="<?php print $item['id'] ?>" class="<?php print $item['class'] ?>" colspan="<?php print $item['colspan'] ?>" rowspan="<?php print $item['rowspan'] ?>">
+  <div class="inner">
+    <?php print $item['entry'] ?>
+  </div>
+</td>
Index: theme/calendar-month-row.tpl.php
===================================================================
RCS file: theme/calendar-month-row.tpl.php
diff -N theme/calendar-month-row.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ theme/calendar-month-row.tpl.php	24 Sep 2010 07:48:03 -0000
@@ -0,0 +1,10 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Template to display a row
+ */
+?>
+<tr>
+  <?php print $inner ?>
+</tr>
