Created
December 8, 2014 15:15
-
-
Save c7tincu/73e1d51845389f4e4351 to your computer and use it in GitHub Desktop.
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
getMaxDateImpl = | |
// Returns the maximum valid month day, given a year and a month. | |
function (year, month) { | |
return ( | |
indexOf([ 0, 2, 4, 6, 7, 9, 11 ], month) !== - 1 ? | |
// January, March, May, July, August, October, or December. | |
31 : | |
indexOf([ 3, 5, 8, 10 ], month) !== - 1 ? | |
// April, June, September, or November. | |
30 : | |
year % 400 === 0 || year % 100 !== 0 && year % 4 === 0 ? | |
// February, leap year. | |
29 : | |
// February, common year. | |
28 | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment