public static function DateHelper::daysInYear

Identifies the number of days in a year for a date.

Parameters

mixed $date: (optional) A date object, timestamp, or a date string. Defaults to NULL, whcih means to use the current date.

Return value

int The number of days in the year.

File

drupal/core/modules/datetime/lib/Drupal/datetime/DateHelper.php, line 469
Contains \Drupal\datetime\DateHelper.

Class

DateHelper
Defines Gregorian Calendar date values.

Namespace

Drupal\datetime

Code

public static function daysInYear($date = NULL) {
  if (!$date instanceof DrupalDateTime) {
    $date = new DrupalDateTime($date);
  }
  if (!$date
    ->hasErrors()) {
    if ($date
      ->format('L')) {
      return 366;
    }
    else {
      return 365;
    }
  }
  return NULL;
}