chronos

A high-performance time library

https://github.com/andrewthad/chronos

Version on this page:1.1.5.1@rev:1
LTS Haskell 22.39:1.1.6.1
Stackage Nightly 2024-10-31:1.1.6.1
Latest on Hackage:1.1.6.1

See all snapshots chronos appears in

BSD-3-Clause licensed by Andrew Martin
This version can be pinned in stack with:chronos-1.1.5.1@sha256:2e70ffed34f8e43951862c3151589568f90028868d1c88b0292b988ade9d318e,3833

Module documentation for 1.1.5.1

Chronos is a performance-oriented time library for Haskell, with a straightforward API. The main differences between this and the time library are:

  • Chronos uses machine integers where possible. This means that time-related arithmetic should be faster, with the drawback that the types are incapable of representing times that are very far in the future or the past (because Chronos provides nanosecond, rather than picosecond, resolution). For most users, this is not a hindrance.

  • Chronos provides ToJSON/FromJSON instances for serialisation.

  • Chronos provides Unbox instances for working with unboxed vectors.

  • Chronos provides Prim instances for working with byte arrays/primitive arrays.

  • Chronos uses normal non-overloaded haskell functions for encoding and decoding time. It provides attoparsec parsers for both Text and ByteString. Additionally, Chronos provides functions for encoding time to Text or ByteString. The http://hackage.haskell.org/package/time time> library accomplishes these with the Data.Time.Format module, which uses UNIX-style datetime format strings. The approach taken by Chronos is faster and catches more mistakes at compile time, at the cost of being less expressive.