Created
August 5, 2010 09:06
-
-
Save cange/509456 to your computer and use it in GitHub Desktop.
Check if a given year is leap year. #learnjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* #learnjs | |
* Check if a given year is leap year. | |
* @param {int} [year] Year to be evaluated. If no date is used defines the client year. | |
* @return {boolean} Returns <em>true</em> is year a leap year, otherwise <em>false</em>. | |
*/ | |
function isLeapYear (year) { | |
return (new Date(year || (new Date).getFullYear(), 1, 29, 0, 0).getMonth() != 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment