Skip to content

Commit 02fd7aa

Browse files
committed
fix: normalize hackathon time parsing
1 parent dc8ee07 commit 02fd7aa

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

components/Activity/Hackathon/utility.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ export const formatPeriod = (startedAt?: TableCellValue, endedAt?: TableCellValu
6767
[formatMoment(startedAt), formatMoment(endedAt)].filter(Boolean).join(' - ');
6868

6969
export const timeOf = (value?: TableCellValue) => {
70-
if (
71-
value == null ||
72-
(typeof value === 'string' && !value.trim()) ||
73-
Array.isArray(value) ||
74-
(typeof value === 'object' && !(value instanceof Date))
75-
)
76-
return NaN;
77-
78-
const time = new Date(value as string | number | Date).getTime();
70+
if (value instanceof Date) return value.getTime();
71+
72+
if (typeof value === 'number') return Number.isFinite(value) ? value : NaN;
73+
74+
const text = firstTextOf(value as TextListLike);
75+
76+
if (!text) return NaN;
77+
78+
const time = Date.parse(text);
7979

8080
return Number.isFinite(time) ? time : NaN;
8181
};

0 commit comments

Comments
 (0)