Monthly Archive for March, 2006

Leap Years

I had to do some date verification code and was just dealing with the leap years. It is a convoluted statement, but it is still reasonably neat:

function is_leap_year($year) {
   return ($year % 4 == 0) &&
      !($year % 100 == 0 && $year % 400 > 0);
}

I sourced the rule from http://scienceworld.wolfram.com/astronomy/LeapYear.html