The problem with most leap year evaluation calculations is that they do not fully take in to account that some leap years just do not exist and are skipped.

As you trawl the internet you will find thousands of examples that all boil down to using modulo math to obtain a true or false boolean value.

Here is a simpler and far more accurate way of dealing with the "Leap Year" problem that uses a prototype constructor to extend the Number object.

Code:

// Leap year problem
Number.prototype.isLeapYear = function(){
return (new Date(this,1,29).getMonth()===1);
}
// alert((2008).isLeapYear());

How? Why?

Simply put, the Javascript date object will automatically roll over the days to the following month, 1st March if 29th of Feb does not exist. This means that the test for month 1 (Feb in JavaScript) will return a boolean true if it happens to be Feb 29th.

You do not need to "Calculate" as the calculation is done within the operating system which is where javascript gets all its times and calculations from. So the days of *x % 4 *and *x % 400* are long gone with a faster method of evaluation that is more accurate.