i-think Twenty-Two

Now with more coherency.

Leap Years

| Comments

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:

leapyears.php
1
2
3
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

Comments