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

Helpscout - Fixing blank screen error on contact details #961

Merged
merged 1 commit into from
Jun 19, 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
8 changes: 8 additions & 0 deletions src/lib/intlFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ describe('intlFormat', () => {

expect(date).toBeNull();
});

it('returns if month is null', () => {
const date = dateFromParts(0, 0, 2000, locale);

expect(date).toBe(
'Invalid Date - you specified 0 (of type number) as a month, which is invalid',
);
});
});
//this test often fails locally. It passes on github.
describe('dateTimeFormat', () => {
Expand Down
10 changes: 9 additions & 1 deletion src/lib/intlFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,16 @@
}

if (typeof year === 'number') {
return dateFormat(DateTime.local(year, month, day), locale);
const date = DateTime.local(year, month, day);
if (date.invalidReason || date.invalidExplanation) {
return `Invalid Date - ${date.invalidExplanation}`;
}
return dateFormat(date, locale);
} else {
const date = DateTime.local().set({ month, day });
if (date.invalidReason || date.invalidExplanation) {
return `Invalid Date - ${date.invalidExplanation}`;

Check warning on line 100 in src/lib/intlFormat.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/intlFormat.ts#L100

Added line #L100 was not covered by tests
}
return dayMonthFormat(day, month, locale);
}
};
Expand Down
Loading