Last active
August 29, 2015 14:07
-
-
Save joshrhoades/7aba5504c0305cde7f67 to your computer and use it in GitHub Desktop.
Helper Date Functions, including determining leap year, and how many days in a month
This file contains hidden or 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
var isLeapYear = function(year) { | |
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; | |
} | |
, getDaysInMonth = function(month, year) { | |
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; | |
} | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment