babashka 2025-05-28

I'm not sure how good my searching skills are in the docs and this channel but is there a built in time library? I saw some old messages that clojure.java-time isn't supported, not sure if that is still accurate. I am seeing some library, cljc.java-time , that can be pulled in externally but was wondering if there is anything I can use that is builtin to just get some basic time functionality like this:

(-> (jt/local-date)
      (jt/minus (jt/days 3))
      str)

The only built-ins are java.time. classes. Libraries are built on top of that. What didn't work before may now work since a lot of stuff was added over time

it appears to me that clojure.java-time may now work too given that there's a bb.edn with a test runner: https://github.com/dm3/clojure.java-time/blob/master/bb.edn

Ahh interesting. Anyways I can work with classes

(str (.minus (java.time.LocalDate/now) 3 java.time.temporal.ChronoUnit/DAYS))

👍 1

These libs aren't built in but you can use them with bb.edn

I got stuck on bb support for some reason I can't remember, there's breadcrumbs here https://github.com/dm3/clojure.java-time/issues/87

Maybe I just wasn't happy with the classes needed to import.

it seems just two classes are missing now: ValueRange and JulianFields

after adding those two classes locally:

Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: definline
Data:     {:type :sci/error, :line 22, :column 1, :file "/private/tmp/clojure.java-time/src/java_time/potemkin/util.clj", :phase "analysis"}
Location: /private/tmp/clojure.java-time/src/java_time/potemkin/util.clj:22:1

The java-time.mock isn't SCI-compatible either unfortunately.

due to definterface and proxy stuff.

both tick and cljc.java-time work though (https://github.com/juxt/tick)

👍 1

tick builds on cljc.java-time if I'm not mistaking