Skip to content

Commit e95b550

Browse files
committed
add time NaN check
pls work in safari 😭
1 parent e739857 commit e95b550

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

frontend/src/lib/utils/time.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const RELATIVE_DIVISIONS: Array<{ amount: number; unit: Intl.RelativeTimeFormatU
1818
];
1919

2020
export const formatRelativeTime = (from: Date, to = new Date()): string => {
21+
if (isNaN(from.getTime()) || isNaN(to.getTime())) {
22+
return 'Unknown';
23+
}
24+
2125
let duration = (from.getTime() - to.getTime()) / 1000;
2226

2327
for (const division of RELATIVE_DIVISIONS) {

0 commit comments

Comments
 (0)