Skip to content

Commit b635c37

Browse files
committed
improve readability of 'should I use?' & reflect maturity of Temporal
1 parent 04c47a4 commit b635c37

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

README.adoc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ image:https://raw.githubusercontent.com/babashka/babashka/master/logo/badge.svg[
77
A Clojure(Script) & babashka library for dealing with time. Intended as a
88
replacement for clj-time.
99

10-
Based on Java 8 time (on the JVM) and js-joda (on JavaScript
11-
runtimes). Javascript's modern date-time API https://github.com/tc39/proposal-temporal[Temporal] is a consideration as an alternative foundation for tick in future. See the
12-
https://github.com/henryw374/tempo[Tempo] library if interested.
10+
Based on `java.time` (on the JVM) and `js-joda` (on JavaScript
11+
runtimes).
1312

14-
See https://www.youtube.com/watch?v=UFuL-ZDoB2U[Henry Widd's talk at Clojure/North 2019] for some background
13+
For a cross-platform library using Javascript's modern date-time API https://github.com/tc39/proposal-temporal[Temporal], see https://github.com/henryw374/tempo[Tempo]
14+
15+
See https://www.youtube.com/watch?v=UFuL-ZDoB2U[Henry Widd's talk at Clojure/North 2019] for more background & rationale.
1516

1617
== Status
1718

@@ -20,14 +21,17 @@ See https://www.youtube.com/watch?v=UFuL-ZDoB2U[Henry Widd's talk at Clojure/Nor
2021

2122
== Should you use Tick for date-time work?
2223

23-
* If you are just working on the JVM and are comfortable with the `java.time` API then raw interop will work just fine.
24-
* If you are working in a Javascript environment then seriously consider using https://github.com/henryw374/cljc.java-time[cljc.java-time]: Its build size https://widdindustries.com/blog/clojurescript-datetime-lib-comparison.html[will not adversely affect your users] (unless in a highly constrained context such as a https://github.com/mfikes/esprit[microcontroller]). The reason is the native Date API is https://maggiepint.com/2017/04/09/fixing-javascript-date-getting-started/[flawed]
25-
* If you meet any of the following criteria, use https://github.com/henryw374/cljc.java-time[cljc.java-time]:
26-
** are creating cross-platform date-time logic
27-
** are not proficient in java.time and would like https://widdindustries.com/why-not-interop/[improved error messages]
28-
** would rather not maintain type hints in your code
29-
* If you meet the criteria to use cljc.java-time but would like a more terse API and the benefits of e.g. https://juxt.github.io/tick/#_substitution[(t/with-clock ...)] but will not miss having every date-time recipe one google search away, then tick might be a good choice. Tick uses https://github.com/henryw374/cljc.java-time[cljc.java-time] so you can always drop to that if Tick is missing something you need.
30-
* Similar in aiming for a terse API, but jvm-only is https://github.com/dm3/clojure.java-time[clojure.java-time].
24+
=== Concision vs Discoverability
25+
26+
* If you are just working on the JVM then raw interop will work of course. Doing so, every java.time recipe is easily found via web search and there are many tutorials to aid understanding.
27+
* New and even experienced users of java.time often trip up on Instant not being calendar-aware, so if you would like https://widdindustries.com/why-not-interop/[improved error messages] then use either https://github.com/henryw374/cljc.java-time[cljc.java-time] (which has the same API as java.time and which underpins tick) or tick.
28+
* To use tick effectively an understanding of java.time is required. If you have that understanding and will spend significant time working with dates and times from Clojure, then learning Tick can be worthwhile because it provides a concise, single-ns API.
29+
30+
=== Cross-Platform and/or just JS runtimes
31+
32+
* If working in a Javascript environment then one should be aware that the legacy Date API is https://maggiepint.com/2017/04/09/fixing-javascript-date-getting-started/[flawed]
33+
* Either tick or https://github.com/henryw374/cljc.java-time[cljc.java-time] (which underpins tick) are sane alternatives to js/Date. The JS build size https://widdindustries.com/blog/clojurescript-datetime-lib-comparison.html[will likely not adversely affect your users] and if you already know java.time then your knowledge will carry over.
34+
* https://github.com/tc39/proposal-temporal[Temporal] is the native JS replacement for the legacy Date (similar to how java.time was on the JVM). It has some overlap with java.time but also some significant differences. Please see the https://github.com/henryw374/tempo[Tempo] library for an alternative to tick with uses that.
3135

3236
== Usage
3337

0 commit comments

Comments
 (0)