Liking cljdoc? Tell your friends :D

Clojurescript

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

Tick currently uses the js-joda library, which aims to replicate the three-ten-backport project.

There is a plan to move to the new platform Javascript Date API, called Temporal

NPM Setup

If you are using Shadow-cljs or just foreign-libs (via Figwheel for example) then there is no npm setup you need to do.

If you are using webpack (cljs :bundle option) 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.

Exclude the transitive cljsjs dependencies so that js-joda is not included twice. The Clojurescript site provides more info.

Optional Timezone & Locale data for reducing build size

The use of timezones and locales is optional to allow a smaller build size.

Minified, gzipped js-joda (what gets pulled in if you use anything of tick) is around 43k (or 205k unzipped) and it doesn’t seem possible to reduce this.

For comparison, a basic Cljs app with React is about 330k unzipped.

So by using Tick you might come close to doubling your build size!

But is that a problem? That depends, but really 330k is my no means small to start with, so likely for the majority of potential users it would not be an issue at all.

Moving the implementation to Tempo will mean the build includes only the compiled Clojurescript of tick itself.

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

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 & Parsing

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

[tick.locale-en-us]

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.

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