Liking cljdoc? Tell your friends :D

Clojurescript

Tick versions 0.4.24-alpha and up require minimum Clojurescript version of 1.10.741

There are extra considerations when using tick with Clojurescript

Tick uses the js-joda library, which aims to replicate the three-ten-backport project. JS-Joda is broken down into a core project (what tick depends on) and additional timezone and locale projects.

NPM Setup

If you are using npm in your build, first add the transitive npm dependencies to your package.json. Assuming you have tick in your deps.edn, from your project directory, run

clj -m cljs.main --install-deps

Now your package.json has the required npm libs added. Shadow actually does this for you, if you are using that.

The only other thing to be aware of is if your build tool supports :foreign-libs (Shadow doesn’t) then you should exclude the transitive cljsjs dependencies. The Clojurescript site provides more info.

Note: For tick versions 0.4.23-alpha and earlier, to use tick on shadow follow this demo

Timezones

If you want to work with timezones, something like this, for example:

(tick/zone "Europe/London")

add the following require:

[tick.timezone]

Note that this is pulling in all of the history of timezones as well. If you don’t need historic data and you want to reduce build size, js-joda provides pre-build packages for just the more recent data.

Formatting

If you want to create custom formatters from patterns, such as "dd MMM yyyy", add this require:

[tick.locale-en-us]

Reducing Tick Build Size

The extra requires for timezones and locales are have been done that way to allow a smaller payload, when the extra libraries are not being used.

Minified, gzipped js-joda (what gets pulled in if you use anything of tick) is around 43k. It could be possible to take advantage of tree-shaking with JSJoda, see this ticket for discussion.

Timezone is an extra 26k, and Locale (just en-US) is an extra 45k

The js-joda timezone dependency contains the timezone database, containing mappings between zone names, their offsets from UTC, and daylight savings(DST) data.

Locale data is needed for custom date formatters which need particular symbols, such as M for month. Due to the size and complexity of using the js-joda-locale, the authors of js-joda-locale have created prebuilt locale packages, for specific locales. en-US is one which is currently packaged for cljs and can be used as suggested above.

OffsetTime and OffsetDateTime

OffsetTime is currently missing from JS-Joda (see JS-Joda issue 240). For now, tick uses LocalTime as the implementation which is not ideal.

OffsetDateTime is also missing but ZonedDateTime has the same functionality so this shouldn’t be a problem.

Can you improve this documentation? These fine people already did:
Henry Widd, Caro & Malcolm Sparks
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close