aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-04-19 15:45:31 +0200
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-04-19 16:35:54 +0200
commit73f3442800dcdc955ae97aeaea369d580c9f3c40 (patch)
treef9ba5e012f4aa4193da4e8d773fec0e009dc4476
parent19797607941a3229c5dae54a3b457e08c89ae207 (diff)
feat: guard against non-number values in duration formatter
-rw-r--r--src/frontend/tubo/utils.cljs7
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))))