refactor: use isLeapYear (#1638)

This commit is contained in:
Piotr Idzik
2024-03-07 05:53:43 +01:00
committed by GitHub
parent d8cfdcd800
commit 4a4ed57d42
3 changed files with 34 additions and 23 deletions

View File

@ -6,6 +6,8 @@
e.g.: mahfoudh.arous.com ->false
*/
import { isLeapYear } from '../Maths/LeapYear'
const getMonthDays = (monthNumber, year) => {
const the31DaysMonths = [1, 3, 5, 7, 8, 10, 12]
const the30DaysMonths = [4, 6, 9, 11]
@ -26,11 +28,8 @@ const getMonthDays = (monthNumber, year) => {
return 30
}
// Check for Leap year
if (year % 4 === 0) {
if (year % 100 !== 0 || (year % 100 === 0 && year % 400 === 0)) {
return 29
}
if (isLeapYear(year)) {
return 29
}
return 28