Liking cljdoc? Tell your friends :D

Intervals

An interval in time is a duration that has a specified beginning and end.

Create an interval

There are multiple ways an interval can be created in tick:

Specify the beginning and the end:

(t/new-interval (t/date-time "2000-01-01T00:00")
                (t/date-time "2001-01-01T00:00"))
{:tick/beginning (t/date-time "2000-01-01T00:00")
 :tick/end (t/date-time "2001-01-01T00:00")}
(t/bounds (t/year 2000))

All of the above result in the same interval:

(= (t/new-interval (t/date-time "2000-01-01T00:00")
                   (t/date-time "2001-01-01T00:00"))
   (t/bounds (t/year 2000))
   {:tick/beginning (t/date-time "2000-01-01T00:00")
    :tick/end (t/date-time "2001-01-01T00:00")})

Interval Manipulation:

The duration of an interval can be modified using extend.

Extend an instant to a interval

(t/extend (t/instant "2000-01-01T00:00")
  (t/new-period 3 :weeks))

Extend an interval:

(t/extend (t/bounds (t/year 2000)) (t/new-period 1 :years))

Shorten an interval:

(t/extend (t/bounds (t/year 2000)) (t/new-period -1 :months))

The beginning of an interval can be modified whilst preserving the duration.

Shift the interval back in time:

(t/<< (t/bounds (t/year 2000)) (t/new-period 6 :months))

Or forward in time:

(t/>> (t/bounds (t/today)) (t/new-duration 1 :half-days))

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close