Fork me on GitHub
#babashka
<
2022-10-23
>
Matthew Twomey04:10:55

I’m sure I’m doing something wrong here as I’m still a relative beginner. I’m trying to make use of cljs.java-time without luck so far. Here’s what I believe to be a clean test, but I’m not sure what’s wrong. Any hints?

% bb
Downloading: com/cognitect/aws/glue/822.2.1193.0/glue-822.2.1193.0.pom from central
Downloading: org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom from central
Downloading: com/cognitect/aws/chime-sdk-identity/821.2.1107.0/chime-sdk-identity-821.2.1107.0.pom from central
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.pom from central
Downloading: com/cognitect/aws/apigateway/822.2.1171.0/apigateway-822.2.1171.0.pom from central
Downloading: com/cognitect/aws/endpoints/1.1.12.307/endpoints-1.1.12.307.pom from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.pom from central
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.pom from central
Downloading: com/widdindustries/cljs.java-time/0.1.20/cljs.java-time-0.1.20.pom from clojars
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar from central
Downloading: com/cognitect/aws/apigateway/822.2.1171.0/apigateway-822.2.1171.0.jar from central
Downloading: com/cognitect/aws/glue/822.2.1193.0/glue-822.2.1193.0.jar from central
Downloading: com/cognitect/aws/chime-sdk-identity/821.2.1107.0/chime-sdk-identity-821.2.1107.0.jar from central
Downloading: com/cognitect/aws/endpoints/1.1.12.307/endpoints-1.1.12.307.jar from central
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.jar from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar from central
Downloading: com/widdindustries/cljs.java-time/0.1.20/cljs.java-time-0.1.20.jar from clojars
Babashka v1.0.164 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require  '[cljc.java-time.local-date :as ld])
java.lang.Exception: Could not find namespace: cljc.java-time.local-date. [at <repl>:1:1]
user=>

Ben Lieberman04:10:57

is that not a typo there at your REPL prompt cljc.java-time as opposed to cljs.java-time?

Matthew Twomey04:10:40

one sec, I’m going to put my head through the wall if that’s the case . Standby

Matthew Twomey04:10:09

:man-facepalming:

Matthew Twomey04:10:45

Ok - there is both a cljs.java-time lib and a cljc.java-time lib. I was reading docs for one and using the other.

Ben Lieberman04:10:00

This is in the category of "useless advice" but having experienced much in the way of painful datetime libraries, I have come to really enjoy tick, it works the way I would expect it to with very minimal issues

Ben Lieberman04:10:23

and I think it is both CLJ and CLJS compatible

Matthew Twomey04:10:50

Well - that’s good advice actually. As I’m new to clojure, I have no preference and was just looking for a way to deal with iso8601 dates that works in babashka. So Thanks, I’ll check that out!

💯 1
Matthew Twomey04:10:51

@U03QBKTVA0N Are you using tick in babashka by chance?

Ben Lieberman04:10:03

Regrettably not, and I am uncertain of its functionality therein

Ben Lieberman04:10:29

I am sure that when the BB wizards come back online they will have good answers for you--better than mine certainly

Matthew Twomey04:10:46

Ok no problem, thanks (I think it may be incompatible). However, I also use straight clojure - so this was a good tip anyhow. Thanks again 🙂

Bob B06:10:16

just to add some color vis-a-vis some prior investigation into tick compatibility with bb: <https://github.com/babashka/babashka/issues/554> - tl;dr tick has some blockers to compatibility with bb; cljc.java-time is compatible (it's actually one of the libraries that gets tested with each build)

borkdude07:10:37

You can also use Java interop directly. java.time is supposed to work: if something is missing, please report it

Matthew Twomey02:10:11

Thanks guys. After exploring many routes, I went with interop. For anyone that comes after, here’s what I did:

;; Read "zoned" ISO8601 timestamp and return a string in human readable local time
(import [java.time.format DateTimeFormatter]
        [java.time ZonedDateTime ZoneId])
(defn lt1 [ts]
  (let [format-string "eeee, MMMM d - h:mm:ss a"
        format (DateTimeFormatter/ofPattern format-string)
        ISO-8601 (DateTimeFormatter/ofPattern "yyyyMMdd'T'HHmmssXXXXX")]
  (-> (ZonedDateTime/parse ts ISO-8601) (.withZoneSameInstant (ZoneId/systemDefault)) (.format format))))

(println (lt1 "20221023T051551Z"))

Matthew Twomey02:10:25

I’m new to clojure and this was my first use of interop, worked very well.

🎉 1
borkdude10:10:13

@U0250GGJGAE That's a pretty good first interop!

🙂 1
teodorlu10:10:12

Hi! For a while, I've been working on https://play.teod.eu/. It's for learning and exploring stuff. Under the hood, it's a big pile of EDN, pandoc, some org-mode/org-roam/emacs lisp, tied together with a babashka/cli tool. I'm sharing my workflow in today's visual tools meeting. Expect this to be informal and unpolished. Posting here since http://play.teod.eu is heavily based on babashka. title: Knowledge management on http://play.teod.eu date: today - October 23rd time: 15:00 UTC / 17:00 CET more info &amp; zoom link: https://clojureverse.org/t/visual-tools-meeting-15-a-common-ground-for-notes-with-kindly

❤️ 1
Noah Bogart14:10:36

I’m thinking of converting a leiningen project to deps.edn and want to smooth over some of the cli complexity (aliases etc) with babashka as a task runner. Has anyone done this before? Any tips or tricks?

borkdude14:10:23

Yes, all the time :)

borkdude14:10:31

I’ll post some tips and tricks when I’m back home but the book should give you all you need. The clojure function and shell function are available by default

Noah Bogart14:10:38

Cool, I’m reading through it now.

borkdude15:10:40

so, for complex clojure invocations, you can just write (clojure "-T:build deploy") or whatever

Noah Bogart15:10:54

Excellent, thank you for the complex examples

borkdude15:10:19

recently I've been putting more code in regular .clj files in a bb directory that I then hook up to tasks

👍 1
borkdude15:10:39

because bb.edn doesn't have linting (yet) and coding in regular .clj files is more comfortable

Noah Bogart15:10:19

That’s clever

borkdude15:10:26

and we also have bb -x now so you can pass arguments directly to a function