mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
@@ -2,6 +2,7 @@
|
||||
"cljs-time util fns for deps"
|
||||
(:require [cljs-time.coerce :as tc]
|
||||
[cljs-time.format :as tf]
|
||||
[cljs-time.core :as t]
|
||||
[clojure.string :as string]
|
||||
[logseq.common.util :as common-util]))
|
||||
|
||||
@@ -90,8 +91,17 @@
|
||||
(string/replace (ymd date) "/" "")))
|
||||
|
||||
(defn journal-day->ms
|
||||
"journal-day format yyyyMMdd"
|
||||
"Converts a journal's :block/journal-day integer into milliseconds"
|
||||
[day]
|
||||
(when day
|
||||
(-> (tf/parse (tf/formatter "yyyyMMdd") (str day))
|
||||
(tc/to-long))))
|
||||
|
||||
(defn ms->journal-day
|
||||
"Converts a millseconds timestamp to the nearest :block/journal-day"
|
||||
[ms]
|
||||
(->> ms
|
||||
tc/from-long
|
||||
t/to-default-time-zone
|
||||
(tf/unparse (tf/formatter "yyyyMMdd"))
|
||||
parse-long))
|
||||
|
||||
@@ -293,12 +293,16 @@
|
||||
(and b (readable-properties @conn b)))
|
||||
":template properties are ignored to not invalidate its property types"))
|
||||
|
||||
(is (= {:logseq.task/deadline (date-time-util/journal-day->ms 20221126)}
|
||||
(readable-properties @conn (db-test/find-block-by-content @conn "only deadline")))
|
||||
(is (= 20221126
|
||||
(-> (readable-properties @conn (db-test/find-block-by-content @conn "only deadline"))
|
||||
:logseq.task/deadline
|
||||
date-time-util/ms->journal-day))
|
||||
"deadline block has correct journal as property value")
|
||||
|
||||
(is (= {:logseq.task/deadline (date-time-util/journal-day->ms 20221125)}
|
||||
(readable-properties @conn (db-test/find-block-by-content @conn "only scheduled")))
|
||||
(is (= 20221125
|
||||
(-> (readable-properties @conn (db-test/find-block-by-content @conn "only scheduled"))
|
||||
:logseq.task/deadline
|
||||
date-time-util/ms->journal-day))
|
||||
"scheduled block converted to correct deadline")
|
||||
|
||||
(is (= 1 (count (d/q '[:find [(pull ?b [*]) ...]
|
||||
|
||||
12
deps/outliner/src/logseq/outliner/pipeline.cljs
vendored
12
deps/outliner/src/logseq/outliner/pipeline.cljs
vendored
@@ -1,16 +1,14 @@
|
||||
(ns logseq.outliner.pipeline
|
||||
"Core fns for use with frontend worker and node"
|
||||
(:require [cljs-time.coerce :as tc]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.format :as tf]
|
||||
[clojure.set :as set]
|
||||
(:require [clojure.set :as set]
|
||||
[datascript.core :as d]
|
||||
[datascript.impl.entity :as de]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.frontend.content :as db-content]
|
||||
[logseq.db.frontend.entity-plus :as entity-plus]
|
||||
[logseq.db.frontend.property :as db-property]
|
||||
[logseq.outliner.datascript-report :as ds-report]))
|
||||
[logseq.outliner.datascript-report :as ds-report]
|
||||
[logseq.common.util.date-time :as date-time-util]))
|
||||
|
||||
(defn filter-deleted-blocks
|
||||
[datoms]
|
||||
@@ -147,8 +145,8 @@
|
||||
|
||||
(defn ^:api get-journal-day-from-long
|
||||
[db v]
|
||||
(when-let [date (t/to-default-time-zone (tc/from-long v))]
|
||||
(let [day (js/parseInt (tf/unparse (tf/formatter "yyyyMMdd") date))]
|
||||
(when v
|
||||
(let [day (date-time-util/ms->journal-day v)]
|
||||
(:e (first (d/datoms db :avet :block/journal-day day))))))
|
||||
|
||||
(defn db-rebuild-block-refs
|
||||
|
||||
Reference in New Issue
Block a user