You are here

function availability_calendars_month_meta in Availability Calendars 6

Same name and namespace in other branches
  1. 5 availability_calendars.module \availability_calendars_month_meta()
  2. 6.2 availability_calendars.inc \availability_calendars_month_meta()
  3. 7.2 availability_calendars.inc \availability_calendars_month_meta()

Utility function to create an array of meta data for the month.

Parameters

int $year:

int $month:

int $startofweek:

Return value

array

2 calls to availability_calendars_month_meta()
availability_calendars_node_edit_form in ./availability_calendars.module
Creates the node edit form.
theme_availability_calendars_month in ./availability_calendars.module
Implementation of hook_theme(). produces our calendars on the viewing of an availability_calendars enabled node.

File

./availability_calendars.module, line 533
Availability Calendars Module.

Code

function availability_calendars_month_meta($year, $month, $settings) {
  $month_meta['daysinmonth'] = date("t", mktime(0, 0, 0, $month, 1, $year));
  $month_meta['firstday'] = date("w", mktime(0, 0, 0, $month, 1, $year)) + $settings->startofweek;
  $tempDays = $month_meta['firstday'] + $month_meta['daysinmonth'];

  // padding
  $month_meta['weeksinmonth'] = ceil($tempDays / 7);

  // Stop empty weeks occuring at start of month
  if ($month_meta['firstday'] > 6) {
    $month_meta['firstday'] = $month_meta['firstday'] - 7;
    $month_meta['weeksinmonth']--;
  }
  return $month_meta;
}