You are here

function partial_date_is_leap_year in Partial Date 7

Returns true, if given $year is a leap year.

Parameters

integer $year:

Return value

boolean true, if year is leap year

2 calls to partial_date_is_leap_year()
partial_date_mktime in ./partial_date.module
Creates a timestamp based on the available components.
partial_date_month_matrix in ./partial_date.module
Maps out the valid month ranges for a given year.

File

./partial_date.module, line 1298
Defines a date element that allows for any combination of date granularity settings.

Code

function partial_date_is_leap_year($year) {
  if (empty($year)) {
    return FALSE;
  }
  if ($year < 1582) {

    // pre Gregorio XIII - 1582
    return $year % 4 == 0;
  }
  else {

    // post Gregorio XIII - 1582
    return $year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0;
  }
}