You are here

function availability_calendars_month_meta in Availability Calendars 5

Same name and namespace in other branches
  1. 6.2 availability_calendars.inc \availability_calendars_month_meta()
  2. 6 availability_calendars.module \availability_calendars_month_meta()
  3. 7.2 availability_calendars.inc \availability_calendars_month_meta()
2 calls to availability_calendars_month_meta()
availability_calendars_node_edit_form in ./availability_calendars.module
theme_availability_calendars_month in ./availability_calendars.module

File

./availability_calendars.module, line 297
Availability Calendars Module

Code

function availability_calendars_month_meta($year, $month, $startofweek) {
  $month_meta['daysinmonth'] = date("t", mktime(0, 0, 0, $month, 1, $year));
  $month_meta['firstday'] = date("w", mktime(0, 0, 0, $month, 1, $year)) + $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;
}