Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting date as 29 Feb for any of the date fields is throwing error across the modules #936

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading