From 4ae38a587c9cd48f6c7b34777f81304011959d1b Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Fri, 30 Dec 2022 21:30:41 +0100 Subject: feat(frontend): Add date formatting helper --- src/frontend/tau/util.cljs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/frontend/tau/util.cljs b/src/frontend/tau/util.cljs index 1a3e243..d23ef9a 100644 --- a/src/frontend/tau/util.cljs +++ b/src/frontend/tau/util.cljs @@ -1,4 +1,12 @@ -(ns tau.util) +(ns tau.util + (:require + ["timeago.js" :as timeago])) + +(defn format-date + [date] + (if (-> date js/Date.parse js/isNaN) + date + (timeago/format date))) (defn format-quantity [num] -- cgit v1.2.3