Transform from and to DateTime with cljs formatters inside a query

I think it would be useful if we could use cljs formatters in Datalog queries.

It is already in use by the LogSeq frontend:

but it is not clear how to use these utility functions in a Datalog

There are plenty articles about transforming the UNIX epoch timestamps into a more malleable form for querying.

The basic strategy seems to convert one’s own DateTime objects manually into UNIX epoch, and run arithmetic operations against those.

Using the cljs formatters would also allow to create string representations, with which we can work differently.

Additionally there is some confusion about Clojure and ClojureScript, and which is offered or used where:

Apart from this

mentions that not all Clojure / ClojureScript interfaces are available. Is there a specific reason why that is the case?

1 Like

Something like this would ideally be possible:

:title "Pages that were created the same day as this journal"
:query [
:find (pull ?p [*])
:in $ ?current
[?journal :block/name ?current]
[?journal :block/created-at ?d]
[?journal :page/journal? true]

[?p :block/created-at ?e]

[(def format (tf/formatter "yyyyMMdd"))]
[(tf/unparse format ?d) ?journal-date]
[(tf/unparse format ?e) ?page-date]
[(= ?journal-date ?page-date)]

:inputs [:current-page]

But it isn’t. What can we do to ease this?

Clojure isn’t offered/used, only ClojureScript is (and partially as mentioned). But people refer to ClojureScript as Clojure, for brevity.

Thanks for the clarification.