mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
refactor: update review.md, update date_time.cljs
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
[clojure.string :as string]
|
||||
[logseq.common.util :as common-util]))
|
||||
|
||||
(def ^:private yyyyMMdd-formatter (tf/formatter "yyyyMMdd"))
|
||||
|
||||
;; (tf/parse (tf/formatter "dd.MM.yyyy") "2021Q4") => 20040120T000000
|
||||
(defn safe-journal-title-formatters
|
||||
[date-formatter]
|
||||
@@ -32,7 +34,7 @@
|
||||
(when journal-title
|
||||
(let [journal-title (common-util/capitalize-all journal-title)]
|
||||
(journal-title-> journal-title
|
||||
#(parse-long (tf/unparse (tf/formatter "yyyyMMdd") %))
|
||||
#(parse-long (tf/unparse yyyyMMdd-formatter %))
|
||||
formatters))))
|
||||
|
||||
(defn format
|
||||
@@ -51,7 +53,7 @@
|
||||
(defn int->journal-title
|
||||
[day date-formatter]
|
||||
(when day
|
||||
(format (tf/parse (tf/formatter "yyyyMMdd") (str day)) date-formatter)))
|
||||
(format (tf/parse yyyyMMdd-formatter (str day)) date-formatter)))
|
||||
|
||||
(defn- get-weekday
|
||||
[date]
|
||||
@@ -94,7 +96,7 @@
|
||||
"Converts a journal's :block/journal-day integer into milliseconds"
|
||||
[day]
|
||||
(when day
|
||||
(-> (tf/parse (tf/formatter "yyyyMMdd") (str day))
|
||||
(-> (tf/parse yyyyMMdd-formatter (str day))
|
||||
(tc/to-long))))
|
||||
|
||||
(defn ms->journal-day
|
||||
@@ -103,5 +105,5 @@
|
||||
(some->> ms
|
||||
tc/from-long
|
||||
t/to-default-time-zone
|
||||
(tf/unparse (tf/formatter "yyyyMMdd"))
|
||||
parse-long))
|
||||
(tf/unparse yyyyMMdd-formatter)
|
||||
parse-long))
|
||||
@@ -3,3 +3,5 @@ You're Clojure(script) expert, you're responsible to check those common errors:
|
||||
- `empty?` should be used instead of `empty` when a boolean value is expected in an expression.
|
||||
|
||||
- If a function does not use `d/transact!`, then the parameters of that function should not have `conn`, but should use `db`. `conn` is mutable, and `db` is immutable.
|
||||
|
||||
- If the arguments of `cljs-time.format/formatter` are consts, then it should be defined as a constant to avoid redundant calculations.
|
||||
|
||||
Reference in New Issue
Block a user