Skip to content

Commit 3bc2e30

Browse files
UzlopakAras Abbasi
and
Aras Abbasi
authored
fix: use isNaN check in isValidDate (#10)
Co-authored-by: Aras Abbasi <a.abbasi@cognigy.com>
1 parent 98d16cb commit 3bc2e30

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/utils/isValidDate.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
export function isValidDate(date: unknown): date is Date {
2-
// An invalid date object returns NaN for getTime() and NaN is the only
3-
// object not strictly equal to itself.
4-
// eslint-disable-next-line no-self-compare
5-
return date !== null && new Date(date as string).getTime() === new Date(date as string).getTime();
2+
// An invalid date object returns NaN for getTime()
3+
return date !== null && Number.isNaN(new Date(date as string).getTime()) === false;
64
}

src/utils/nextRunAt.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ const dateForTimezone = (timezoneDate: Date, timezone?: string): moment.Moment =
1919

2020
export function isValidHumanInterval(value: unknown): value is string {
2121
const transformedValue = humanInterval(value as string);
22-
// eslint-disable-next-line no-restricted-globals
23-
return typeof transformedValue === 'number' && isNaN(transformedValue) === false;
22+
return typeof transformedValue === 'number' && Number.isNaN(transformedValue) === false;
2423
}
2524

2625
/**

0 commit comments

Comments
 (0)