Updated if condition for Leap year detection

This commit is contained in:
Rak Laptudirm
2021-01-21 10:22:15 +05:30
committed by GitHub
parent d8395e7c9f
commit 96ec303875

View File

@ -21,11 +21,7 @@ const getMonthDays = (monthNumber, year) => {
if (the30DaysMonths.includes(monthNumber)) { return 30 }
// Check for Leap year
if (year % 4 === 0) {
if ((year % 100 !== 0) || (year % 100 === 0 && year % 400 === 0)) {
return 29
}
}
if (((year % 400) === 0)||(((year % 100) != 0) && ((year % 4) === 0))) { return 29 }
return 28
}