Skip to content

Commit dc8ee07

Browse files
committed
fix: avoid epoch fallback for missing hackathon times
1 parent 1e5b881 commit dc8ee07

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

components/Activity/Hackathon/utility.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +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-
const time = new Date((value as string) || 0).getTime();
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();
7179

7280
return Number.isFinite(time) ? time : NaN;
7381
};

0 commit comments

Comments
 (0)