Ejemplo n.º 1
0
 /**
  * Return a set of arrays to construct a calendar month for the given date
  *
  * @param int $month
  *        	the month, default is current local month
  * @param int $year
  *        	the year in four digit format, default is current local year
  * @param string $format
  *        	the string indicating how to format the output
  *        	
  * @return array $month[$row][$col]
  *        
  * @access public
  * @static
  *
  */
 static function getCalendarMonth($month = 0, $year = 0, $format = DATE_CALC_FORMAT)
 {
     if (empty($year)) {
         $year = Calc::dateNow('%Y');
     }
     if (empty($month)) {
         $month = Calc::dateNow('%m');
     }
     $month_array = array();
     // date for the first row, first column of calendar month
     if (DATE_CALC_BEGIN_WEEKDAY == 1) {
         if (Calc::firstOfMonthWeekday($month, $year) == 0) {
             $curr_day = Calc::dateToDays('01', $month, $year) - 6;
         } else {
             $curr_day = Calc::dateToDays('01', $month, $year) - Calc::firstOfMonthWeekday($month, $year) + 1;
         }
     } else {
         $curr_day = Calc::dateToDays('01', $month, $year) - Calc::firstOfMonthWeekday($month, $year);
     }
     // number of days in this month
     $daysInMonth = Calc::daysInMonth($month, $year);
     $weeksInMonth = Calc::weeksInMonth($month, $year);
     for ($row_counter = 0; $row_counter < $weeksInMonth; $row_counter++) {
         for ($column_counter = 0; $column_counter <= 6; $column_counter++) {
             $month_array[$row_counter][$column_counter] = Calc::daysToDate($curr_day, $format);
             $curr_day++;
         }
     }
     return $month_array;
 }