diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-04-19 15:45:31 +0200 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-04-19 16:35:54 +0200 |
commit | 73f3442800dcdc955ae97aeaea369d580c9f3c40 (patch) | |
tree | f9ba5e012f4aa4193da4e8d773fec0e009dc4476 /src | |
parent | 19797607941a3229c5dae54a3b457e08c89ae207 (diff) |
feat: guard against non-number values in duration formatter
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/tubo/utils.cljs | 7 |
1 files changed, 4 insertions, 3 deletions
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)))) |