Browse Source

feat(frontend): rename date formatting utils

Miguel Ángel Moreno 1 year ago
parent
commit
c2cba71697

+ 1 - 1
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]

+ 1 - 1
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]

+ 8 - 1
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

+ 1 - 5
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}