babashka

Chase 2025-05-28T18:17:06.156399Z

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)

borkdude 2025-05-28T18:22:22.047719Z

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

borkdude 2025-05-28T18:28:13.687679Z

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

Chase 2025-05-28T18:28:55.261009Z

Ahh interesting. Anyways I can work with classes

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

👍 1
borkdude 2025-05-28T18:29:33.532409Z

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

2025-05-28T19:01:43.225639Z

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

2025-05-28T19:02:24.964239Z

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

borkdude 2025-05-28T19:18:45.890589Z

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

borkdude 2025-05-28T19:42:36.391569Z

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

borkdude 2025-05-28T19:45:02.915999Z

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

borkdude 2025-05-28T19:45:12.313779Z

due to definterface and proxy stuff.

borkdude 2025-05-28T19:46:49.728679Z

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

👍 1
borkdude 2025-05-28T19:46:58.952359Z

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