In the past I’ve not done a ton with times, but when I did in CLJS I used cljs-time. At the moment it’s still the only thing I see out there, but the fact that it is trying to imitate clj-time when java-time is better for the back-end makes me a little uncomfortable. What are some recommendations for time handling in cljs?
goog.time (https://google.github.io/closure-library/api/goog.date.html) is a nice CLJS solution, if it’s able to meet your need, because it’s already included in the Closure library.
There’s this https://github.com/gfZeng/time.clj/
I’ve only used it a tiny bit tho.
I was wondering about the closure solution. Thanks!
Does anyone have practical comparisons of using one solution vs. another? For example, “cheapest” (included with clojurescript) would be the closure solution. What do moment, luxon, or dayjs facilitate more readily (besides, as with all things closure, better documentation)?
I don’t have a comparison but I used moment, dayjs, luxon. Here’s my impressions:
- date-fns - we want functional programming! So we provided functions to offer those features.
- Luxon - I(that author @icambron) maintained moment.js and I think we can design a better library by: making dates immutable, better time zone, better API names, etc.
- Dayjs - we want a light-weight and immutable version of moment.js while we don’t want to learn a new library. Let’s just do it with moment.js APIs.
FWIW, I use
clj-time on the server side and
moment.js on the client-side, with a bunch of utility functions on top. I’m not perfectly happy with either, and I think there is still place for a small cljc library with a nicer interface.
Glad you asked @Webdev_Tory ;-), because there is now a fully cross-platform Clojure(Script) date/time library, ‘tick’: https://github.com/juxt/tick. The api sits atop java.time on the jvm and a js implementation of java.time (jsr310).
We are building up to an announce shortly and I will be speaking about this at Clojure/North in April.
Linked from the readme are the docs, and I’ll point out there is a section specifically about extra considerations wrt Tick and Clojurescript https://github.com/juxt/tick/blob/master/docs/cljs.adoc
Happy to field any questions here.
I am very excited to look in to tick!