You are here

function date_iso_weeks_in_year in Date 7.3

Same name and namespace in other branches
  1. 8 date_api/date_api.module \date_iso_weeks_in_year()
  2. 5.2 date_api.module \date_iso_weeks_in_year()
  3. 6.2 date_api.module \date_iso_weeks_in_year()
  4. 6 date_api.module \date_iso_weeks_in_year()
  5. 7 date_api/date_api.module \date_iso_weeks_in_year()
  6. 7.2 date_api/date_api.module \date_iso_weeks_in_year()

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.

2 calls to date_iso_weeks_in_year()
DateApiTestCase::testDateApi in date_api/tests/DateApiTestCase.test
Test date_format_date().
DateObject::difference in date_api/date_api.module
Computes difference between two days using a given measure.

File

date_api/date_api.module, line 2050
This module will make the date API available to other modules.

Code

function date_iso_weeks_in_year($date = NULL) {
  if (empty($date)) {
    $date = date_now();
  }
  elseif (!is_object($date)) {
    $date = new DateObject($date);
  }
  if (is_object($date)) {
    date_date_set($date, $date
      ->format('Y'), 12, 28);
    return $date
      ->format('W');
  }
  return NULL;
}