You are here

public static function PersianDateHelper::daysInYear in Persian Date for Drupal 8 8.4

Same name and namespace in other branches
  1. 8 src/PersianDateHelper.php \Drupal\persian_date\PersianDateHelper::daysInYear()

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

Parameters

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

Return value

int The number of days in the year.

Overrides DateHelper::daysInYear

File

src/PersianDateHelper.php, line 460

Class

PersianDateHelper

Namespace

Drupal\persian_date

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;
}