You are here

function date_iso_weeks_in_year in Date 8

Same name and namespace in other branches
  1. 5.2 date_api.module \date_iso_weeks_in_year()
  2. 6.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()

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) A date object, timestamp, or a date string. Defaults to current date.

Return value

integer The number of ISO weeks in a year.

1 call to date_iso_weeks_in_year()
DateAPITest::testDateAPI in date_api/lib/Drupal/date_api/Tests/DateAPITest.php
@todo.

File

date_api/date_api.module, line 826
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) {
  if (!$date instanceof DrupalDateTime) {
    $date = new DrupalDateTime($date);
  }
  if ($date instanceof DrupalDateTime && !$date
    ->hasErrors()) {
    date_date_set($date, $date
      ->format('Y'), 12, 28);
    return $date
      ->format('W');
  }
  return NULL;
}