#inst 有谓词吗?

Is there a predicate for #inst?

#inst 有谓词吗?

dev:cljs.user=> #inst "1985-04-12"
#inst "1985-04-12T00:00:00.000-00:00"

dev:cljs.user=> (type #inst "1985-04-12")
#object[Date]

dev:cljs.user=> (tagged-literal? #inst "1985-04-12")
false

, 所以 (answer-to-this-question? #inst "1985-04-12") returns true?

如果这样的谓词不存在,是否可以造一个?

到目前为止我已经想出了:

(= "function Date() { [native code] }" (-> #inst "1985-04-12" type str))
;; -> true

inst? 是在 Clojure 1.9 中添加的。 自从 73ab8ff8f 于 2016 年年中登陆 Clojurescript 以来,它也可用于 Clojurescript。

您还可以在 任何 版本的 ClojureScript 中使用 instance? 函数:

(instance? js/Date #inst "2017-11-14")
;; -> true