Liking cljdoc? Tell your friends :D

Introduction

Time is an illusion. Lunchtime doubly so.

— Douglas Adams
The Hitchhiker's Guide to the Galaxy

Tick is a comprehensive Clojure(Script) library designed to make it easier to write programs that involve time and date calculations:

  • Functions to manipulating time, easily and succinctly (stable)

  • Powerful functions for slicing and dicing time intervals (stable)

  • Implementation of Allen’s interval algebra (stable)

  • Support for iCalendar serialization (work-in-progress)

In many business domains, dates are as fundamental as numbers and strings. It’s often desirable to have date-heavy business logic portable across platforms. Tick supports both Clojure and ClojureScript, with an identical API.

Tick is implemented using (a very thin wrapper over) the api of java.time and an understanding of the concepts behind java.time will be very useful when working with tick, because tick entities are java.time entities (Instant, LocalTime etc). Where tick doesn’t provide the api you need, you can look at the java.time api to see if there alternatives. If you cannot find the help you need in the tick documentation, it is quite likely that someone will have had the same query and had it resolved on Stack Overflow.

Status

Tick is currently in alpha status. By alpha, we mean that the library’s API may change in future. The quality of tick is deemed adequate for real-world use but do let us know if you come across any unexpected behaviour and bugs.

License

Tick is copyrighted by JUXT LTD. and licensed as free software under the open-source MIT License.

The MIT License (MIT)

Copyright © 2016-2018 JUXT LTD.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comparison to other time libraries

Java 8 time

Java 8’s java.time API is both influenced by, and an improvement on, Joda Time.

Unlike older JDK dates and calendars, instances in java.time are immutable so can be considered values in Clojure. For this reason, there is no reason to wrap these values. Consequently, there is full interoperability between tick and java.time. Where tick does not provide a part of java.time’s functionality, java.time can be called directly in either Clojure or Clojurescript.

Because tick is built on java.time, Clojure programs must run on Java 8 or higher.

clj-time and cljs-time

Most Clojure applications use clj-time which is based on Joda Time. However, cljs-time objects are mutable goog.date objects which in turn wrap JavaScript Date objects.

This works OK as a proxy for Instant, but is not a great foundation for local dates etc.

The author of cljs-time, Andrew McVeigh, has said he would ideally move cljs-time off goog.date but is unlikely to do so at this point. For one thing, there could be more than a few current users relying on the JS Date nature of the cljs-time objects.

Taking a fresh look at the date/time landscape, we now have java.time (JSR-310) and implementations in both Java and Javascript and so it is possible to create tick, which combines the excellent JSR-310 with an expressive, cross-platform Clojure(Script) API.

For some use cases it is possible to write cross-platform code with clj/s-time, conditionally requiring clj-time or cljs-time in a cljc file. In our experience though, the fact that cljs-time doesn’t have complete fidelity with clj-time often comes to 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