Skip to content

Commit

Permalink
fix(dateTimeParse): parse 0 as valid dateTime (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS authored Sep 30, 2024
1 parent 8b8d132 commit 8df988e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ describe('Parser', () => {
expect(Boolean(date)).toEqual(false);
});

it('should return DateTime in case of 0 input arg', () => {
const date = dateTimeParse(0)?.toISOString();
expect(date).toEqual('1970-01-01T00:00:00.000Z');
});

test.each<[string | undefined, string]>([
['ru', '07 авг. 2021'],
['en', '07 Aug 2021'],
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const dateTimeParse: DateTimeParser<DateTimeOptionsWhenParsing> = (
input,
options,
): DateTime | undefined => {
if (!input) {
if (input === undefined) {
return undefined;
}

Expand Down

0 comments on commit 8df988e

Please sign in to comment.