/**
  * get a list of month days
  *
  * @access protected
  * @param
  * @return
  */
 protected function getMonthWeekDays($year, $month)
 {
     static $month_days = array();
     if (isset($month_days[$year][$month])) {
         return $month_days[$year][$month];
     }
     $month_str = $month < 10 ? '0' . $month : $month;
     $begin_month = new ilDate($year . '-' . $month_str . '-01', IL_CAL_DATE);
     $begin_month_info = $begin_month->get(IL_CAL_FKT_GETDATE);
     $days = array(0 => 'SU', 1 => 'MO', 2 => 'TU', 3 => 'WE', 4 => 'TH', 5 => 'FR', 6 => 'SA');
     for ($i = 0; $i < $begin_month_info['wday']; $i++) {
         next($days);
     }
     for ($i = $begin_month_info['yday']; $i < $begin_month_info['yday'] + ilCalendarUtil::_getMaxDayOfMonth($year, $month); $i++) {
         if (($current_day = current($days)) == false) {
             $current_day = reset($days);
         }
         $month_days[$year][$month][$current_day][] = $i;
         next($days);
     }
     return $month_days[$year][$month];
 }
 /**
  * init period of events
  *
  * @access protected
  * @param ilDate seed
  * @return
  */
 protected function initPeriod(ilDate $seed)
 {
     switch ($this->type) {
         case self::TYPE_DAY:
             $this->start = clone $seed;
             $this->end = clone $seed;
             $this->start->increment(IL_CAL_DAY, -2);
             $this->end->increment(IL_CAL_DAY, 2);
             break;
         case self::TYPE_WEEK:
             $this->start = clone $seed;
             $start_info = $this->start->get(IL_CAL_FKT_GETDATE, '', 'UTC');
             $day_diff = $this->weekstart - $start_info['isoday'];
             if ($day_diff == 7) {
                 $day_diff = 0;
             }
             $this->start->increment(IL_CAL_DAY, $day_diff);
             $this->start->increment(IL_CAL_DAY, -1);
             $this->end = clone $this->start;
             $this->end->increment(IL_CAL_DAY, 9);
             break;
         case self::TYPE_MONTH:
             $year_month = $seed->get(IL_CAL_FKT_DATE, 'Y-m', 'UTC');
             list($year, $month) = explode('-', $year_month);
             $this->start = new ilDate($year_month . '-01', IL_CAL_DATE);
             $this->start->increment(IL_CAL_DAY, -6);
             $this->end = new ilDate($year_month . '-' . ilCalendarUtil::_getMaxDayOfMonth($year, $month), IL_CAL_DATE);
             $this->end->increment(IL_CAL_DAY, 6);
             break;
         case self::TYPE_INBOX:
             $this->start = $seed;
             $this->end = clone $this->start;
             $this->end->increment(IL_CAL_MONTH, 3);
             break;
     }
     return true;
 }