From 73f3442800dcdc955ae97aeaea369d580c9f3c40 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Fri, 19 Apr 2024 15:45:31 +0200 Subject: feat: guard against non-number values in duration formatter --- src/frontend/tubo/utils.cljs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/frontend') diff --git a/src/frontend/tubo/utils.cljs b/src/frontend/tubo/utils.cljs index 58d6172..643031c 100644 --- a/src/frontend/tubo/utils.cljs +++ b/src/frontend/tubo/utils.cljs @@ -42,6 +42,7 @@ (defn format-duration [num] - (let [duration (js/Date. (* num 1000)) - slice #(.slice % (if (>= (.getUTCHours duration) 1) 11 14) 19)] - (-> duration (.toISOString) slice))) + (let [duration (and (not (js/isNaN num)) (js/Date. (* num 1000))) + slice (and duration #(.slice % (if (>= (.getUTCHours duration) 1) 11 14) 19))] + (when slice + (-> duration (.toISOString) slice)))) -- cgit v1.2.3