CalendarInterval

Build Status

Functions for working with calendar intervals.

Key ideas:

Examples

use CalendarInterval

iex> ~I"2018-06".precision
:month

iex> CalendarInterval.next(~I"2018-12-31")
~I"2019-01-01"

iex> CalendarInterval.nest(~I"2018-06-15", :minute)
~I"2018-06-15 00:00/23:59"

iex> CalendarInterval.relation(~I"2018-01", ~I"2018-02/12")
:meets

iex> Enum.count(~I"2016-01-01/12-31")
366

References

This library is heavily inspired by "Exploring Time" talk by Eric Evans [1] where he mentioned the concept of "Countable Time" and introduced me to "Allen's Interval Algebra" [2].

I've also given a talk about some of these ideas at Empex NYC 2018: video, slides.

Installation

Add to mix.exs:

def deps do
  [
    {:calendar_interval, "~> 0.2.0"}
  ]
end

License

Apache 2.0