Accessing js/Date in `result-transform` function?

Hey there,

I’m trying to display certain specific dates with my templates that are not available via dynamic variables.

I thought that there might be a hacky way to use queries and the result-transform function to get around the need of writing a plugin.

Currently my code looks something like this:

{:query [:find ?today :in $ ?today]
 :inputs [:today]
 :result-transform (fn [result]
                     (.getFullYear (new js/Date (first result))))
}

but I get the error

sci eval failed: Could not resolve symbol: js/Date

Why is this symbol not available?

1 Like

Welcome.

  • Most symbols are not available.
  • There are already some plugins that work with dates.
    • An alternative to plugins is file custom.js , which is equally powerful.
  • If you share a more specific need, we can offer more specific options.

@mentaloid is right, most symbols are not available.

Actually i have a PR to introdutce the js/Date to the advanced query feat: allow js/Date in the advanced query by CNLHC · Pull Request #10529 · logseq/logseq (github.com)