Skip to content

Instantly share code, notes, and snippets.

@joshrhoades
Last active August 29, 2015 14:07
Show Gist options
  • Save joshrhoades/7aba5504c0305cde7f67 to your computer and use it in GitHub Desktop.
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
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