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 3 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,16 @@ describe('LocaleFormat', () => {
dec.toUTCString() + ' is not a valid date'
);
});
it('should return false for a non leap year date', () => {
const nonLeapYear: Date = new Date(2021, 1, 29);
RonMichaud marked this conversation as resolved.
Show resolved Hide resolved
expect(LocaleFormat.validDate(nonLeapYear.getMonth(), nonLeapYear.getDate(), nonLeapYear.getFullYear())).toBeTruthy(
nonLeapYear.toUTCString() + ' is not a valid date'
)});

it('should return true for a leap year date', () => {
const leapYear: Date = new Date(2020, 1, 29);
expect(LocaleFormat.validDate(leapYear.getMonth(), leapYear.getDate(), leapYear.getFullYear())).toBeTruthy(
leapYear.toUTCString() + ' is a valid date'
)});
});
});
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