Fork me on GitHub
#announcements
<
2019-12-29
>
Lu01:12:39

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" https://github.com/luciodale/inst

👍 4
valtteri14:12:45

Cool! For simple cases there are also some hidden gems in the Google Closure library https://google.github.io/closure-library/api/goog.date.relative.html

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

✔️ 8
Lu14:12:12

Thanks for pointing it out! 🙂

metasoarous11:12:27

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

👆 4
Lu11:12:32

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

Lu18:12:30

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

borkdude16:12:59

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