public function get_weekly_calendar($timestamp = false, $id = '', $class = '')
 {
     $options = Eab_Options::get_instance();
     if (!is_object($options)) {
         $options = new Eab_Options();
     }
     $timestamp = $timestamp ? $timestamp : $this->get_local_time();
     $year = date("Y", $timestamp);
     $month = date("m", $timestamp);
     //$query = Eab_CollectionFactory::get_upcoming(strtotime("{$year}-{$month}-01 00:00"));
     $query = Eab_CollectionFactory::get_upcoming_weeks(strtotime("{$year}-{$month}-01 00:00"));
     $this->_events = $query->posts;
     $date = $timestamp ? $timestamp : $this->get_local_time();
     $sunday = $this->sunday($date);
     // Timestamp of first Sunday of any date
     if (!($start = $this->_data->get_option('weekly_calendar_start')) or $start > 23) {
         $start = 10;
     }
     // Set a default working time start
     $first = $start * 3600 + $sunday;
     // Timestamp of the first cell of first Sunday
     if (!($end = $this->_data->get_option('weekly_calendar_end')) or $end < 1) {
         $end = 24;
     }
     // Set a default working time end
     $last = $end * 3600 + $sunday;
     // Timestamp of the last cell of first Sunday
     if (!($interval = $this->_data->get_option('weekly_calendar_interval')) or $interval < 10 or $interval > 60 * 12) {
         $interval = 120;
     }
     // Set a default interval in minutes
     $step = $interval * 60;
     // Timestamp increase interval to one cell below
     $days = $this->arrange(array(0, 1, 2, 3, 4, 5, 6), -1);
     // Arrange days acc. to start of week
     $post_info = array();
     foreach ($this->_events as $event) {
         $post_info[] = $this->_get_item_data($event);
     }
     $tbl_id = $id;
     $tbl_id = $tbl_id ? "id='{$tbl_id}'" : '';
     $tbl_class = $class;
     $tbl_class = $tbl_class ? "class='{$tbl_class}'" : '';
     $ret = '';
     $ret .= "<table width='100%' {$tbl_id} {$tbl_class}>";
     $ret .= $this->_get_table_meta_row('thead');
     $ret .= '<tbody>';
     $ret .= $this->_get_first_row();
     $todays_no = date("w", $this->get_local_time());
     // Number of today
     for ($t = $first; $t < $last; $t = $t + $step) {
         foreach ($days as $key => $i) {
             // Not sure if it's current fix, but it works!
             if ($i == 0) {
                 $i = 7;
             }
             if ($i == -1) {
                 $from = $this->secs2hours($t - $sunday);
                 $to = $this->secs2hours($t - $sunday + $step);
                 $ret .= "<td class='wpmudevevents-weekly-calendar-hours-mins'>" . $from . " - " . $to . "</td>";
             } else {
                 $current_cell_start = $t + $i * 86400;
                 $current_cell_end = $current_cell_start + $step;
                 $this->reset_event_info_storage();
                 foreach ($post_info as $ipost) {
                     $count = count($ipost['event_starts']);
                     for ($k = 0; $k < $count; $k++) {
                         $start = strtotime($ipost['event_starts'][$k]);
                         $end = strtotime($ipost['event_ends'][$k]);
                         if ($start < $current_cell_end && $end > $current_cell_start) {
                             if ($options->get_option('weekly_calendar_display')) {
                                 $this->set_event_info_author(array('start' => $start, 'end' => $end), array('start' => $current_cell_start, 'end' => $current_cell_end), $ipost);
                             } else {
                                 $this->set_event_info(array('start' => $start, 'end' => $end), array('start' => $current_cell_start, 'end' => $current_cell_end), $ipost);
                             }
                         }
                     }
                 }
                 $activity = $this->get_event_info_as_string($i);
                 $now = $todays_no == $i ? 'class="today"' : '';
                 if ($this->get_local_time() < $current_cell_end && $this->get_local_time() > $current_cell_start) {
                     $now = 'class="now"';
                 }
                 $ret .= "<td {$now}>{$activity}</td>";
             }
         }
         $ret .= '</tr><tr>';
         // Close the last day of the week
     }
     $ret .= $this->_get_last_row();
     $ret .= '</tbody>';
     $ret .= $this->_get_table_meta_row('tfoot');
     $ret .= '</table>';
     return $ret;
 }