Skip to content

Commit

Permalink
Selecting date as 29 Feb for any of the date fields is throwing error…
Browse files Browse the repository at this point in the history
… across the modules (#936)

* FEB_29th_selection

* #GOCLD 2298 test cases

* #GOCLD 2298 test cases

* #GOCLD 2298 test cases
  • Loading branch information
preetigairi authored Mar 13, 2024
1 parent fe0dee6 commit 5d480b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@ describe('LocaleFormat', () => {
dec.toUTCString() + ' is not a valid date'
);
});
it('should return true for a leap year date', () => {
const feb = 1;
expect(LocaleFormat.validDate(feb, 29, 2024)).toBe(true);
});

it('should return false for a non leap year date', () => {
const feb = 1;
expect(LocaleFormat.validDate(feb, 29, 2023)).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class LocaleFormat {
if (day <= validDays[month]) {
return true;
}
if (year % 4 === 0 && month === 2 && day === 29) {
if (year % 4 === 0 && (month + 1) === 2 && day === 29) {
return true;
}
return false;
Expand Down

0 comments on commit 5d480b2

Please sign in to comment.