Tuesday, July 24, 2007

Leap Years



In investigating making an age of majority checker, I started thinking about leap years. I know of one person total that was born on February 29th. Statistically speaking, there are bound to be more.

Anyway, here's a good little function that'll return true if you have a leap year. and false if you don't

function checkYear(year) {
return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0;
}

Labels: , ,

0 Comments:

Post a Comment

<< Home