Просмотр исходного кода

refactor: apply more changes according to review.md

rcmerci 4 месяцев назад
Родитель
Сommit
290124d665

+ 3 - 1
src/main/frontend/components/views.cljs

@@ -47,6 +47,8 @@
             [promesa.core :as p]
             [rum.core :as rum]))
 
+(def ^:private yyyy-MM-dd-formatter (tf/formatter "yyyy-MM-dd"))
+
 (defn- get-scroll-parent
   [config]
   (if (:sidebar? config)
@@ -1375,7 +1377,7 @@
                      (instance? js/Date value)
                      (some->> (tc/to-date value)
                               (t/to-default-time-zone)
-                              (tf/unparse (tf/formatter "yyyy-MM-dd")))
+                              (tf/unparse yyyy-MM-dd-formatter))
                      (and (coll? value) (every? uuid? value))
                      (keep #(db/entity [:block/uuid %]) value)
                      :else

+ 7 - 3
src/main/frontend/date.cljs

@@ -19,6 +19,10 @@
 
 (def custom-formatter (tf/formatter "yyyy-MM-dd'T'HH:mm:ssZZ"))
 
+(def ^:private mmm-do-yyyy-formatter (tf/formatter "MMM do, yyyy"))
+(def ^:private yyyy-MM-dd-formatter (tf/formatter "yyyy-MM-dd"))
+(def ^:private yyyy-MM-dd-HH-mm-formatter (tf/formatter "yyyy-MM-dd HH:mm"))
+
 (defn journal-title-formatters
   []
   (common-date/journal-title-formatters (state/get-date-formatter)))
@@ -36,7 +40,7 @@
     (->> (cond->> input
            (string? input) (tf/parse (tf/formatters :date-time-no-ms)))
          (t/to-default-time-zone)
-         (tf/unparse (tf/formatter "MMM do, yyyy")))
+         (tf/unparse mmm-do-yyyy-formatter))
     (catch :default _e
       nil)))
 
@@ -67,7 +71,7 @@
 
 (defn journal-name-s [s]
   (try
-    (journal-name (tf/parse (tf/formatter "yyyy-MM-dd") s))
+    (journal-name (tf/parse yyyy-MM-dd-formatter s))
     (catch :default _e
       (log/error :parse-journal-date {:message  "Unable to parse date to journal name, skipping."
                                       :date-str s})
@@ -159,7 +163,7 @@
 (defn int->local-time-2
   [n]
   (tf/unparse
-   (tf/formatter "yyyy-MM-dd HH:mm")
+   yyyy-MM-dd-HH-mm-formatter
    (t/to-default-time-zone (tc/from-long n))))
 
 (def iso-parser (tf/formatter "yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'"))

+ 4 - 3
src/main/frontend/db/async.cljs

@@ -19,6 +19,8 @@
             [logseq.common.util :as common-util]
             [promesa.core :as p]))
 
+(def ^:private yyyyMMdd-formatter (tf/formatter "yyyyMMdd"))
+
 (def <q db-async-util/<q)
 (def <pull db-async-util/<pull)
 (comment
@@ -196,11 +198,10 @@
   [journal-title]
   (when-let [date (date/journal-title->int journal-title)]
     (let [future-days (state/get-scheduled-future-days)
-          date-format (tf/formatter "yyyyMMdd")
-          current-day (tf/parse date-format (str date))
+          current-day (tf/parse yyyyMMdd-formatter (str date))
           future-date (t/plus current-day (t/days future-days))
           future-day (some->> future-date
-                              (tf/unparse date-format)
+                              (tf/unparse yyyyMMdd-formatter)
                               (parse-long))
           start-time (date/journal-day->utc-ms date)
           future-time (tc/to-long future-date)]