Liking cljdoc? Tell your friends :D

Clojurescript

There are extra considerations when using tick with Clojurescript

TL;DR to use tick on shadow, follow this demo

Tick uses an npm lib, js-joda which is packaged in cljsjs.

This is done as a convenience so that users need not have npm installed and won’t need to add build steps in order to try tick out. However, if you are using Shadow, Node, Webpack etc you may wish to depend on the NPM libraries directly. The Clojurescript site provides advice on how to replace cljsjs dependencies.

Shadow ignores the :foreign-libs directive in the deps.cljs dependency file of that lib, so requires a shim to create the namespace that would normally come from the foreign-lib directive.

Dropping to java.time

Tick depends on cljc.java-time which is the easiest way to access the full java.time api underneath tick.

Timezones

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

 (tick/zone "Europe/London")

add the following require:

[tick.timezone]

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

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.

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 & Malcolm Sparks
Edit on GitHub

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

× close