Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by

The following code fails with an exception:

(cljs.reader/read-string (pr-str (new js/Date 200 5)))

 #error {:message "Unrecognized date/time syntax: 200-05-31T23:06:32.000-00:00",
         :data {:type :reader-exception},
         :cause #object[Error Error: Unrecognized date/time syntax: 200-05-31T23:06:32.000-00:00]}

Note that a JS Date handles a year 200 fine.

Note also that the following works fine:

(cljs.reader/read-string "#inst \"0200-05-31T23:06:32.000-00:00\"")

This suggests that the correct fix may be to format the year with 4 characters in https://github.com/clojure/clojurescript/blob/r1.10.773-2-g946348da/src/main/cljs/cljs/core.cljs#L10173 using normalize

2 Answers

0 votes
by

Reproduce in one-line

clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.764"}}}' -m cljs.main -re node -e "(require '[clojure.edn :as edn]) (edn/read-string (pr-str (new js/Date 200 5)))"

in cljs it prints

#inst "200-06-01T03:06:28.000-00:00"

then the reader can't read it.

In JVM clojure

clj -Srepro -e "(require '[clojure.edn :as edn]) (edn/read-string (pr-str (doto (new java.util.Date) (.setYear -1700))))"

It prints #inst "0200-07-06T12:35:31.383-00:00" without any problems

0 votes
by
...