1 date.inc date_iso_weeks_in_year($date = NULL)

Identifies the number of ISO weeks in a year for a date.

December 28 is always in the last ISO week of the year.

Parameters

mixed $date: (optional) The current date object, or a date string. Defaults to NULL.

Return value

int: The number of ISO weeks in a year.

File

core/includes/date.inc, line 866
Date API functions.

Code

function date_iso_weeks_in_year($date = NULL) {
  if (empty($date)) {
    $date = date_now();
  }
  elseif (!is_object($date)) {
    $date = new BackdropDateTime($date);
  }

  if (is_object($date)) {
    date_date_set($date, $date->format('Y'), 12, 28);
    return $date->format('W');
  }
  return NULL;
}