You are here

function date_calc_get_calendar_month in Date 6

Same name and namespace in other branches
  1. 5.2 date_php4/date_php4_calc.inc \date_calc_get_calendar_month()
  2. 6.2 date_php4/date_php4_calc.inc \date_calc_get_calendar_month()

Return a set of arrays to construct a calendar month for the given date.

Parameters

int $month: The month.

int $year: The 4 digit year. Do not add leading 0's for years prior to 1000.

string $format: The string indicating how to format the output.

Return value

array $month[$row][$col].

1 call to date_calc_get_calendar_month()
date_calc_get_calendar_year in date_php4/date_php4_calc.inc
Return a set of arrays to construct a calendar year for the given date

File

date_php4/date_php4_calc.inc, line 773

Code

function date_calc_get_calendar_month($month = 0, $year = 0, $format = DATE_CALC_FORMAT) {
  if (empty($year)) {
    $year = date_calc_get_year();
  }
  if (empty($month)) {
    $month = date_calc_get_month();
  }
  $month_array = array();

  // date for the first row, first column of calendar month
  if (variable_get('date_first_day', 1) == 1) {
    if (date_calc_first_of_month_weekday($month, $year) == 0) {
      $curr_day = date_calc_date_to_days('01', $month, $year) - 6;
    }
    else {
      $curr_day = date_calc_date_to_days('01', $month, $year) - date_calc_first_of_month_weekday($month, $year) + 1;
    }
  }
  else {
    $curr_day = date_calc_date_to_days('01', $month, $year) - date_calc_first_of_month_weekday($month, $year);
  }

  // number of days in this month
  $date_calc_days_in_month = date_calc_days_in_month($month, $year);
  $date_calc_weeks_in_month = date_calc_weeks_in_month($month, $year);
  for ($row_counter = 0; $row_counter < $date_calc_weeks_in_month; $row_counter++) {
    for ($column_counter = 0; $column_counter <= 6; $column_counter++) {
      $month_array[$row_counter][$column_counter] = date_calc_days_to_date($curr_day, $format);
      $curr_day++;
    }
  }
  return $month_array;
}