This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-29
Channels
- # announcements (7)
- # babashka (36)
- # beginners (67)
- # braveandtrue (11)
- # cider (8)
- # clojure (52)
- # clojure-conj (4)
- # clojure-poland (1)
- # clojure-spec (9)
- # clojure-uk (8)
- # clojurescript (42)
- # core-typed (11)
- # cursive (4)
- # emacs (1)
- # fulcro (1)
- # graalvm (24)
- # hoplon (10)
- # hyperfiddle (1)
- # off-topic (30)
- # re-frame (7)
- # reitit (1)
- # sql (1)
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
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"
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 https://github.com/borkdude/spartan.test tl;dr: testing for scripts written with babashka can also be used with clojure itself, if needed