You are here

function date_iso_weeks_in_year in Date 6.2

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 date_api.module \date_iso_weeks_in_year()
  4. 7.3 date_api/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()

Identify 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:

string $type:

Return value

integer

2 calls to date_iso_weeks_in_year()
DateAPITestCase::testDateAPI in tests/date_api.test
date_difference in ./date_api.module
Compute difference between two days using a given measure.

File

./date_api.module, line 975
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_iso_weeks_in_year($date = NULL, $type = DATE_OBJECT) {
  if (empty($date)) {
    $date = date_now();
  }
  if (!is_object($date)) {
    $date = date_convert($date, $type, DATE_OBJECT);
  }
  if (is_object($date)) {
    date_date_set($date, date_format($date, 'Y'), 12, 28);
    return date_format($date, 'W');
  }
  return NULL;
}