aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-01-28 02:42:12 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-01-28 03:00:13 +0100
commitc2cba716976a140114ceccee12e76482c5f261df (patch)
tree89728815e00955d63f01618d82085a26cd51281a /src/frontend
parent39d21f31a44be24772b4b126fbfb583b716494a1 (diff)
feat(frontend): rename date formatting utils
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/tubo/components/comments.cljs2
-rw-r--r--src/frontend/tubo/components/items.cljs2
-rw-r--r--src/frontend/tubo/util.cljs9
-rw-r--r--src/frontend/tubo/views/stream.cljs6
4 files changed, 11 insertions, 8 deletions
diff --git a/src/frontend/tubo/components/comments.cljs b/src/frontend/tubo/components/comments.cljs
index 4a94e07..8e5e2ec 100644
--- a/src/frontend/tubo/components/comments.cljs
+++ b/src/frontend/tubo/components/comments.cljs
@@ -34,7 +34,7 @@
[:p.break-words {:dangerouslySetInnerHTML {:__html text}}]]
[:div..flex.items-center.my-2
[:div.mr-4
- [:p (util/format-date upload-date)]]
+ [:p (util/format-date-ago upload-date)]]
(when (and like-count (> like-count 0))
[:div.flex.items-center.my-2
[:i.fa-solid.fa-thumbs-up.text-xs]
diff --git a/src/frontend/tubo/components/items.cljs b/src/frontend/tubo/components/items.cljs
index 3368894..39179e6 100644
--- a/src/frontend/tubo/components/items.cljs
+++ b/src/frontend/tubo/components/items.cljs
@@ -59,7 +59,7 @@
[:i.fa-solid.fa-video.text-xs]
[:p.mx-2 (util/format-quantity stream-count)]])
[:div.flex.my-1.justify-between
- [:p (util/format-date upload-date)]
+ [:p (util/format-date-ago upload-date)]
(when view-count
[:div.flex.items-center.h-full.pl-2
[:i.fa-solid.fa-eye.text-xs]
diff --git a/src/frontend/tubo/util.cljs b/src/frontend/tubo/util.cljs
index 9137cbe..ea42ab6 100644
--- a/src/frontend/tubo/util.cljs
+++ b/src/frontend/tubo/util.cljs
@@ -2,7 +2,14 @@
(:require
["timeago.js" :as timeago]))
-(defn format-date
+(defn format-date-string
+ [date]
+ (-> date
+ js/Date.parse
+ js/Date.
+ .toDateString))
+
+(defn format-date-ago
[date]
(if (-> date js/Date.parse js/isNaN)
date
diff --git a/src/frontend/tubo/views/stream.cljs b/src/frontend/tubo/views/stream.cljs
index dc24ac3..232d134 100644
--- a/src/frontend/tubo/views/stream.cljs
+++ b/src/frontend/tubo/views/stream.cljs
@@ -97,11 +97,7 @@
(when upload-date
[:div.sm:text-base.text-sm.mt-1.whitespace-nowrap
[:i.fa-solid.fa-calendar]
- [:span.ml-2
- (-> upload-date
- js/Date.parse
- js/Date.
- .toDateString)]])]]
+ [:span.ml-2 (util/format-date-string upload-date)]])]]
(when (and show-description? (not (empty? description)))
[:div.py-3.flex.flex-wrap.min-w-full
[:div {:dangerouslySetInnerHTML {:__html description}