Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.58 KB

README.md

File metadata and controls

49 lines (34 loc) · 1.58 KB

Kronos

Kronos is a library to facilitate simple arithmetic operations between timestamps. At Dernier Cri (my ex-company), we often have to handle DateTime. Kronos was designed to avoid having to constantly convert DateTime into timestamps and vice-verça.

If you are looking for a complete library of time and date management, Kronos is (maybe) not the ideal solution, and I recommend Timex!

Kronos relies on Mizur to decorate numerical values of typing information.

The library supports Mizur arithmetic operations, Timestamps collisions, inclusions between timestamps intervals (via Mizur.Range), and truncation of timestamps. I invite you to read the full documentation for more information!

https://hexdocs.pm/kronos

Small examples

import Kronos
use Kronos.Infix # Same of Mizur.Infix

{:ok, t} = new({2010, 12, 20}, {0, 0, 0})
# You can use timestamp or DateTime.t as parameter for Kronos.new

r = t + ~t(2)day + ~t(3)hour + ~t(10)minute + ~t(13)second
IO.puts Kronos.to_string(r) # will print "2010-12-22 03:10:13Z"

Installation

If available in Hex, the package can be installed by adding kronos to your list of dependencies in mix.exs:

def deps do
  [{:kronos, "~> 1.0.0"}]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/kronos.