Fork me on GitHub
#babashka
<
2022-03-01
>
bcaccinolo08:03:00

Hi, following the steps of this todo project https://clojurians.slack.com/archives/CLX41ASCS/p1642783827147200 , I'm having fun using babashka and htmx. I'm reaching a point where I would like to add some more interactions and with htmx I can else use _hyperscript or javascript. But is there a way to write clojurescript for the front as easily as it is to write clojure for the backend withe babashka ? Shadowcljs looks kinda complex to use in regard of the plug-and-play approach of babashka.

bcaccinolo09:03:25

Awesome ! It's exactly that! Thanks @U04V15CAJ . Furthermore, scittle will pave the road to allow me to test reagent at some point. Smooth learning curve 🙂

pez14:03:37

With bb 0.6.8 I can

(System/getProperty "babashka.version")
=> "0.6.8" 
With 0.7.6:
(System.getProperty "babashka.version")
; : Could not resolve symbol: System.getProperty user /Users/pez/Projects/...
Did I miss a memo?

lukasz14:03:16

2nd one is not the same tho

🙏 1
borkdude14:03:17

You made a typo in the second one.

pez15:03:48

I see it now. 😃

✔️ 1
Max18:03:57

Is clojure.instant not completely included in babashka? It seems like only read-instant-date is available, parse-timestamp and all the other fns are missing

Max18:03:25

Or is there a better way to parse datetimes/instants with babashka?

borkdude18:03:14

java.time package

Max18:03:54

Would you be interested in adding the rest of clojure.instant? Should I make a ticket?

borkdude19:03:18

Part of clojure.instant is really only there to support some of the libraries in the ecosystem to run from source with bb, but overall it isn't the recommended way to deal with dates in bb: this is what java.time is for.

borkdude19:03:22

Adding the the full support for clojure.instant brings in some classes that are supposed to be superseded by java.time and that I consider legacy so it would be a waste to make that part of the binary imo.

borkdude19:03:20

(def ^:private formatter
  (java.time.format.DateTimeFormatter/ofPattern "yyyy-MM-dd"))
 
(java.time.LocalDate/parse s formatter)

👍 1
borkdude19:03:42

I'll try to add parse-timestamp and see what it adds, just out of curiosity

borkdude19:03:14

since read-instant-date is using parse-timestamp it's probably ok

borkdude19:03:03

yep, that adds basically nothing so I'm ok with adding that

Max20:03:28

Awesome thanks! I appreciate the tip about java.time as well, parsing datetimes from strings was surprisingly tricky

borkdude20:03:13

java.time is very powerful but it has a bit of a learning curve

leifericf14:12:13

I stumbled into this thread when searching for a solution to my problem today. Here is the solution I came up with to compare two dates:

(:import [java.time.format DateTimeFormatter]
         [java.time LocalDate])

(defn has-token-expired? [token]
  (let [format (DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss.SSSSSS")
        timestamp (LocalDate/parse (:expiresOn token) format)]
    (.isAfter (LocalDate/now) timestamp)))
I'm leaving this here in case it's useful to someone else in the future 🙂

👍 1
clojure-spin 2
leifericf14:12:13

I stumbled into this thread when searching for a solution to my problem today. Here is the solution I came up with to compare two dates:

(:import [java.time.format DateTimeFormatter]
         [java.time LocalDate])

(defn has-token-expired? [token]
  (let [format (DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss.SSSSSS")
        timestamp (LocalDate/parse (:expiresOn token) format)]
    (.isAfter (LocalDate/now) timestamp)))
I'm leaving this here in case it's useful to someone else in the future 🙂

👍 1
clojure-spin 2