Fork me on GitHub

Inst, a multi language cljs tool to parse instants into "Time Interval Ago" or "In Time Interval" i.e. "5 minutes ago" "in 2 minutes"

👍 4

Cool! For simple cases there are also some hidden gems in the Google Closure library

cljs.user> (require '[ :as gdate])
cljs.user> (gdate/format (.parse js/Date "2019-12-29T14:06:41.079Z"))
"3 minutes ago" 

✔️ 8

Thanks for pointing it out! 🙂


Does it support the reverse mapping from friendly strings to times?

👆 4

Not currently, but hey! It’s a good idea 💡 will add this in the next hours :)


I have been playing with it for a bit and although I implemented a safe way to go back to the Inst, it’s just an approximation of the original value (as the exact seconds are lost during the conversion to string when they go above the hour unit). For this reason, I don’t think it’s a useful feature to add, as the reverse algorithm produces an output that doesn’t exactly match with the initial Inst


spartan.test: a spartan testing library compatible with babashka tl;dr: testing for scripts written with babashka can also be used with clojure itself, if needed