Skip to content

Commit b867eaf

Browse files
committed
fix: time diff helper
1 parent 774f8f1 commit b867eaf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Shared/Helpers.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,14 @@ export const getTimeDifference = ({
790790
return fallbackString
791791
}
792792

793-
const duration = moment.duration(moment(endTime).diff(moment(startTime)))
793+
const start = moment(startTime)
794+
const end = moment(endTime)
795+
if (!start.isValid() || !end.isValid()) {
796+
return fallbackString
797+
}
798+
799+
const diff = Math.abs(end.diff(start))
800+
const duration = moment.duration(diff)
794801

795802
const units = [
796803
{ label: 'd', value: duration.days() },

0 commit comments

Comments
 (0)