Skip to content
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
3 changes: 2 additions & 1 deletion src/dateTime/dateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ function getTimestamp(
} else if (format === undefined) {
const [dateObject, timezoneOrOffset] = parseDateString(input);
if (Object.keys(dateObject).length === 0) {
return [NaN, NaN];
// fallback to native Date parse
return getTimestamp(new Date(input), timezone, locale, format, fixedOffset);
}
[ts] = getTimestampFromObject(
dateObject,
Expand Down
6 changes: 6 additions & 0 deletions src/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ describe('Parser', () => {
expect(date).toEqual(TESTED_DATE_STRING);
});

it('should return DateTime in case of using Date.toString() value', () => {
const nativeDate = new Date('2023-11-06T00:00:00.000Z');
const date = dateTimeParse(nativeDate.toString());
expect(date?.toISOString()).toEqual(nativeDate.toISOString());
});

it('should return DateTime in case of using relative date string', () => {
const date = dateTimeParse('now')?.toISOString();
expect(date).toEqual(new Date().toISOString());
Expand Down
Loading