joda-time

abs

(abs o)
Returns the absolute value of a period or a duration.

(abs (negate x)) == (abs x)

abuts?

(abuts? i oi)
True if this interval abut with the other one.

after?

(after? x)(after? x y)(after? x y & more)
Returns non-nil if time entities are ordered from the latest to the earliest
(same as `>`):

  (after? (date-time "2011") (date-time "2010") (date-time "2009"))
  => true

  (after? (interval (date-time "2009") (date-time "2010"))
          (date-time "2008"))
  => truthy...

Works with instants, date-times, partials and intervals.

as-map

(as-map o)
Converts a period or a partial into a map representation.

A period is converted into a map where keys correspond to names of
`DurationFieldTypes`. Only durations supported by the provided period are
included in the result.

A partial is converted into a map where keys correspond to
`DateTimeFieldTypes`.

An instant/date-time is converted into a map where keys correspond to
`DateTimeFieldTypes`. Every date-time field type will be present in the
result.

before?

(before? x)(before? x y)(before? x y & more)
Returns non-nil if time entities are ordered from the earliest to the latest
(same as `<`):

  (before? (date-time "2009") (date-time "2010") (date-time "2011"))
  => truthy...

  (before? (interval (date-time "2009") (date-time "2010"))
           (date-time "2011"))
  => truthy...

Works with instants, date-times, partials and intervals.

chronology

(chronology nm)(chronology nm tz)
Produces a chronology of the specified type (lowercase) and the given time
zone (optional):

  (chronology :coptic)
  => #<CopticChronology CopticChronology [Europe/Vilnius]>

  (chronology :coptic :UTC)
  => #<CopticChronology CopticChronology [UTC]>

Time zones are resolved through the `timezone` function.

contains?

(contains? i o)
True if the interval contains the given
instant/partial/interval.

date-time

(date-time)(date-time o)(date-time y m)(date-time y m d)(date-time y m d h)(date-time y m d h mm)(date-time y m d h mm s)(date-time y m d h mm s mmm)
Constructs a DateTime out of:

* another instant, a number of milliseconds or a partial date
* a java (util/sql) Date/Timestamp or a Calendar
* an ISO formatted string
* a map with keys corresponding to the names of date-time field types
and an (optional) chronology.
* a map with keys `partial` representing any partial date and `base`
representing a date-time to be used for fields missing in the partial
(defaults to epoch).
* different arities accepting a number of fields in order of Year, Month,
Day, Hour, Minute, Second, Millis. The fields not specified will be defaulted
to the minimum field value.

When called with no arguments produces a value of `DateTime/now`.

days

(days o__1718__auto__)
Constructs a Days period representing the given number of days. Given a time entity tries to extract the number of days. Given another period, extracts its days part.

days-in

(days-in G__2188)(days-in x__2170__auto__ y__2171__auto__)
Number of days in the given period/interval/pair of
instants, date-times or partials.

duration

(duration o)
Constructs a Duration out of a number, interval, string, other duration or a
map containing:

  - start and end instants
  - start instant and a period
  - end instant and a period

  (duration 1000)
  => #<Duration PT1S>

  (duration (interval 0 1000))
  => #<Duration PT1S>

  (duration "PT1S")
  => #<Duration PT1S>

  (duration (duration 1000))
  => #<Duration PT1S>

  (duration {:start 0, :end 1000})
  => #<Duration PT1S>

  (duration {:start 0, :period (seconds 1)})
  => #<Duration PT1S>

  (duration {:end 0, :period (seconds 1)})
  => #<Duration PT1S>

duration?

(duration? x)
True if the given object is an instance of `ReadableDuration`.

end

(end i)
Gets the end of the interval.

formatter

(formatter fmt & more)
Constructs a DateTimeFormatter out of a number of

* format strings - "YYYY/mm/DD", "YYY HH:MM", etc.
* ISODateTimeFormat formatter names - :date, :time-no-millis, etc.
* other DateTimeFormatter instances

The resulting formatter will parse all of the requested formats and print
using the first one.

friday?

(friday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a friday.

gap

(gap i oi)
Gets the gap between this interval and the other one.

hours

(hours o__1718__auto__)
Constructs a Hours period representing the given number of hours. Given a time entity tries to extract the number of hours. Given another period, extracts its hours part.

hours-in

(hours-in G__2190)(hours-in x__2170__auto__ y__2171__auto__)
Number of hours in the given period/interval/pair of
instants, date-times or partials. Also handles durations.

in-zone

(in-zone dt zone)

instant

(instant)(instant o)
Constructs an Instant out of another instant, java date, calendar, number of
millis or a formatted string:

  (instant)
  => #<Instant ...now...>

  (instant (java.util.Date.))
  => #<Instant ...now...>

  (instant 1000)
  => #<Instant 1970-01-01T00:00:01.000Z>

  (j/instant "1970-01-01T00:00:01.000Z")
  => #<Instant 1970-01-01T00:00:01.000Z>

instant?

(instant? x)
True if the given object is an instance of `ReadableInstant`.

interval

(interval o)(interval start end)
Constructs an interval out of another interval, a string,
start and end instants/date-times or a map with the
following keys (where start/end may be instants, date-times
or number of milliseconds):

* start/end
* start/period
* period/end
* start/duration
* duration/end

  (j/interval "2010/2013")
  => #<Interval 2010-01-01T00:00:00.000+02:00/2013-01-01T00:00:00.000+02:00>

  (j/interval (j/date-time "2010") (j/date-time "2013"))
  => #<Interval 2010-01-01T00:00:00.000+02:00/2013-01-01T00:00:00.000+02:00>

  (j/interval {:start (j/date-time "2010"), :end (j/date-time "2013")})
  => #<Interval 2010-01-01T00:00:00.000+02:00/2013-01-01T00:00:00.000+02:00>

  (j/interval {:start (j/date-time "2010"), :period (j/years 3)})
  => #<Interval 2010-01-01T00:00:00.000+02:00/2013-01-01T00:00:00.000+02:00>

interval?

(interval? x)
True if the given object is an instance of `ReadableInterval`.

iterate

(iterate f initial v & vs)
Returns a lazy sequence of `initial` , `(apply f initial v vs)`, etc.

Useful when you want to produce a sequence of dates/periods/intervals, for
example:

  (iterate plus (millis 0) 1)
  => (#<Period PT0S> #<Period PT0.001S> #<Period PT0.002S> ...)

  (iterate plus (local-date "2010-01-01") (years 1))
  => (#<LocalDate 2010-01-01> #<LocalDate 2011-01-01> ...)

  (iterate move-end-by (interval 0 1000) (seconds 1))
  => (#<Interval 00.000/01.000> #<Interval 00.000/02.000> ...)

local-date

(local-date)(local-date o__1986__auto__)(local-date year month)(local-date year month day)
Constructs a LocalDate out of 

* another partial (which must have all of the needed fields)
* an instant or a number of milliseconds
* a java (util/sql) Date/Timestamp or a Calendar
* an ISO formatted string
* a map with keys corresponding to the names of date-time field types
  and an (optional) chronology.
* a number of ints for the multi-argument varieties of partial constructors.

When called with no arguments produces a value of `LocalDate/now`.

local-date-time

(local-date-time)(local-date-time o__1986__auto__)(local-date-time year month)(local-date-time year month day)(local-date-time year month day hour)(local-date-time year month day hour minute)(local-date-time year month day hour minute second)(local-date-time year month day hour minute second millis)
Constructs a LocalDateTime out of 

* another partial (which must have all of the needed fields)
* an instant or a number of milliseconds
* a java (util/sql) Date/Timestamp or a Calendar
* an ISO formatted string
* a map with keys corresponding to the names of date-time field types
  and an (optional) chronology.
* a number of ints for the multi-argument varieties of partial constructors.

When called with no arguments produces a value of `LocalDateTime/now`.

local-time

(local-time)(local-time o__1986__auto__)(local-time hour minute)(local-time hour minute second)(local-time hour minute second millis)
Constructs a LocalTime out of 

* another partial (which must have all of the needed fields)
* an instant or a number of milliseconds
* a java (util/sql) Date/Timestamp or a Calendar
* an ISO formatted string
* a map with keys corresponding to the names of date-time field types
  and an (optional) chronology.
* a number of ints for the multi-argument varieties of partial constructors.

When called with no arguments produces a value of `LocalTime/now`.

max

(max o & os)
Maximum of the given date-times/instants/partials/periods/intervals.

max-value

(max-value p)
The maximum value of a property.

merge

(merge o & os)
Merges two or more periods or partials together.

## Periods

Merges periods together to produce a Period. Type of the resulting period is
an aggregate of all period types participating in a merge.

Periods further in the arglist will overwrite earlier ones having overlapping
period types.

  (merge (years 2) (months 3))
  => #<Period P2Y3M>

  (merge (years 2) (years 3))
  => #<Period P3Y>

## Partials

Merges partials into an instance of Partial using the chronology of the
first partial:

  (merge (partial {:year 5}) (partial {:year 3, :monthOfYear 4}))
  => #<Partial 0003-04>

Will throw an exception if the resulting partial is invalid:

  (merge (local-date "2008-02-29") (partial {:year 2010}))
  => Exception ...

millis

(millis o)
Constructs a Period representing the given number of milliseconds.  Given a
time entity tries to extract the number of millis. Given another period,
extracts it's millis part.

millis-in

(millis-in G__2196)(millis-in x__2170__auto__ y__2171__auto__)
Number of millis in the given period/interval/pair of
instants, date-times or partials. Also handles durations.

min

(min o & os)
Minimum of the given date-times/instants/partials/periods/intervals.

min-value

(min-value p)
The minimum value of a property.

minus

(minus o & os)
Subtracts one or more time entity from the first entity. Minus is defined
for the following entities:

* periods: period - {period, number}
* durations: duration - {duration, number}
* partials: partial - period
* instants: instant - {duration, period}

Calling `minus` with a single argument has the same effect as `negate` (for
durations and periods).  `(minus x y z)` has the same effect as `(plus x
(negate y) (negate z))`.

minutes

(minutes o__1718__auto__)
Constructs a Minutes period representing the given number of minutes. Given a time entity tries to extract the number of minutes. Given another period, extracts its minutes part.

minutes-in

(minutes-in G__2192)(minutes-in x__2170__auto__ y__2171__auto__)
Number of minutes in the given period/interval/pair of
instants, date-times or partials. Also handles durations.

monday?

(monday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a monday.

month-day

(month-day)(month-day o__1986__auto__)(month-day month day)
Constructs a MonthDay out of 

* another partial (which must have all of the needed fields)
* an instant or a number of milliseconds
* a java (util/sql) Date/Timestamp or a Calendar
* an ISO formatted string
* a map with keys corresponding to the names of date-time field types
  and an (optional) chronology.
* a number of ints for the multi-argument varieties of partial constructors.

When called with no arguments produces a value of `MonthDay/now`.

months

(months o__1718__auto__)
Constructs a Months period representing the given number of months. Given a time entity tries to extract the number of months. Given another period, extracts its months part.

months-in

(months-in G__2184)(months-in x__2170__auto__ y__2171__auto__)
Number of months in the given period/interval/pair of
instants, date-times or partials.

move-end-by

(move-end-by i & os)
Moves the end instant of the interval by the sum of given
periods/durations/numbers of milliseconds.

  (move-end-by (interval 0 10000) 3000 (duration 1000) (seconds 1))
  => #<Interval 00.000/15.000>

Accepts negative values:

  (move-end-by (interval 0 10000) -5000)
  => #<Interval 00.000/05.000>

Fails if the new end instant falls before the start instant.

  (move-end-by (interval 0 10000) -11000)
  => IllegalArgumentException...

move-end-to

(move-end-to i new-end)
Moves the end of the interval to the given instant/partial.

 (move-end-to (interval 0 10000) (instant 15000))
 => #<Interval 00.000/15.000>

Fails if the new end instant/partial falls before the start instant.

 (move-end-to (interval 0 10000) -1)
 => IllegalArgumentException...

move-start-by

(move-start-by i & os)
Moves the start instant of the interval by the sum of given
periods/durations/numbers of milliseconds:

  (move-start-by (interval 0 10000) 3000 (duration 1000) (seconds 1))
  => #<Interval 05.000/10.000>

Accepts negative values:

  (move-start-by (interval 0 10000) -5000)
  => #<Interval 00.000/10.000>

Fails if the new start instant falls after the end instant.

  (move-start-by (interval 0 10000) 11000)
  ; => IllegalArgumentException...

move-start-to

(move-start-to i new-start)
Moves the start instant of the interval to the given instant.

 (move-start-to (interval 0 10000) (instant 5000))
 => #<Interval 05.000/10.000>

Fails if the new start instant falls after the end instant.

 (move-start-to (interval 0 10000) 15000)
 => IllegalArgumentException...

negate

(negate o)
Negates a period or a duration.

(negate (negate x)) == x

overlap

(overlap i oi)
Gets the overlap between this interval and the other one.

overlaps?

(overlaps? i oi)
True if this interval overlaps the other one.

parse-date-time

(parse-date-time f__2283__auto__ dt-str__2284__auto__)
Parses an instance of DateTime with the given parsing formatter.
To parse an ISO-formatted string you can simply invoke the `date-time` constructor.

parse-local-date

(parse-local-date f__2283__auto__ dt-str__2284__auto__)
Parses an instance of LocalDate with the given parsing formatter.
To parse an ISO-formatted string you can simply invoke the `local-date` constructor.

parse-local-date-time

(parse-local-date-time f__2283__auto__ dt-str__2284__auto__)
Parses an instance of LocalDateTime with the given parsing formatter.
To parse an ISO-formatted string you can simply invoke the `local-date-time` constructor.

parse-local-time

(parse-local-time f__2283__auto__ dt-str__2284__auto__)
Parses an instance of LocalTime with the given parsing formatter.
To parse an ISO-formatted string you can simply invoke the `local-time` constructor.

parse-mutable-date-time

(parse-mutable-date-time f__2283__auto__ dt-str__2284__auto__)
Parses an instance of MutableDateTime with the given parsing formatter.
To parse an ISO-formatted string you can simply invoke the `mutable-date-time` constructor.

partial

(partial)(partial o)
Constructs a Partial out of another partial or a map with keys corresponding
to the names of date-time field types and an (optional) chronology.

  (partial {})
  ; => #<Partial []>

  (partial {:year 5})
  ; => #<Partial 0005>

  (partial {:year 5, :chronology (ISOChronology/getInstanceUTC)})
  ; => #<Partial 0005>

  (partial {:era 1, :centuryOfEra 2, :yearOfEra 3, :dayOfYear 5})
  ; => #<Partial [era=1, centuryOfEra=2, yearOfEra=3, dayOfYear=5]>

partial-interval

(partial-interval o)(partial-interval start end)
Constructs an interval from two partials or a map containing:

* start and end keys
* start and a period
* end and a period

Partials must have equal type (contain an equal set of
DateTimeFieldTypes) and be contiguous:

  (partial-interval (local-date "2010-01-01")
                    (local-date "2011-02-01"))

Intervals are inclusive of the start partial and exclusive of the end
partial.

partial-interval?

(partial-interval? x)
True if the given object is an instance of `PartialInterval`.

partial?

(partial? x)
True if the given object is an instance of `ReadablePartial` (includes local
dates/times).

period

(period)(period o)(period o t)
Constructs a Period. Takes a number, duration, string,
interval, another period or a map.

  (period {:years 2, :months 3})
  => #<Period P1Y3M>

  (period {:start 0, :end 1000})
  => #<Period PT1S>

  (period {:start 0, :duration 1000})
  => #<Period PT1S>

  (period {:duration 1000, :end 0})
  => #<Period PT1S>

  (period 1000)
  => #<Period PT1S>

  (period "PT1S")
  => #<Period PT1S>

  (period (duration 1000))
  => #<Period PT1S>

  (period (interval 0 1000))
  => #<Period PT1S>

Accepts two arguments where the second one is the desired type of the period
(either an instance of `PeriodType` or a vector of duration type keywords,
e.g. `[:seconds, :millis]`):

  (period {:start 0, :duration (* 1000 1000 1000)} [:days])
  => #<Period P11D>

  (period {:start 0, :duration (* 1000 1000 1000)} (period-type :weeks))
  => #<Period P1W>)

period-type

(period-type t & types)
Either gets the period type of the given `ReadablePeriod` or constructs a
`PeriodType` out of the provided duration types.

  (period-type :years :months :weeks :days :hours :minutes :seconds :millis)
  => #<PeriodType PeriodType[Standard]>

  (period-type (years 1))
  => #<PeriodType PeriodType[Years]>

period-type->seq

(period-type->seq period-type)
Constructs a sequence of duration type names out of a PeriodType.

(period-type->seq standard-period-type)
=> [:years :months :weeks :days :hours :minutes :seconds :millis]

(period-type->seq (period-type (years 1))
=> [:years]

period?

(period? x)
True if the given object is an instance of `ReadablePeriod`.

plus

(plus o & os)
Sums two or more time entities together. Plus is defined for the following
entities:

* periods: period + {period, number}
* durations: duration + {duration, number}
* partials: partial + period
* instants: instant + {duration, period}

## Periods

Sums periods and numbers together to produce a Period. No period
normalization or field overflows happen in the `plus` function.

  (plus (years 1) (years 1) (months 1))
  => #<Period P2Y1M>

Numbers are only allowed if type of the sum of the periods preceding the
number is single (e.g. years or months).

  (plus (years 1) 10)
  => #<Period P11Y>

  (plus (years 1) (months 1) 10)
  => Exception ...

  (plus (years 1) 10 (months 1))
  => #<Period P11Y1M>

Will always return the result of type `Period`, albeit with the most specific
`PeriodType`.

## Durations

Sums durations and numbers of milliseconds together to produce a Duration.

  (plus (duration 10) (duration 10) 10)
  => #<Duration PT0.030S>

## Partials

Sums a partial and periods together to produce a partial. Produces the most
specific type:

  (plus (local-date "2010-01-01") (years 2))
  => #<LocalDate 2012-01-01>

  (plus (partial {:year 2010}) (years 2))
  => #<Partial 2012>

Discards periods which aren't supported by the partial:

  (plus (partial {:year 2010}) (days 500))
  => #<Partial 2010>

## Instants

Sums an instant and periods, durations and numbers of milliseconds together
to produce an instant. Works with Instants and DateTimes.  Returns the most
specific type:

  (plus (date-time 0) 1000 (duration 1000) (years 40))
  => #<DateTime 2010-01-01T03:00:02.000+02:00>

  (plus (instant 0) 1000 (duration 1000) (years 40))
  => #<Instant 2010-01-01T00:00:02.000Z>

print

(print dt)(print df dt)
Prints a date entity using the provided formatter. Without the formatter
prints in ISO format.

properties

(properties o)
Retrieves properties of a Partial or a DateTime.

For example, get a date with the last day of month:

  (-> (properties date) :dayOfMonth with-max-value)

or get maximum values for all of the properties:

  (->> (properties date)
       (map (comp max-value val))

property

(property o key)
Retrieves a property with the given key. Nil if the property doesn't
exist.

For example:

  (-> date properties :dayOfMonth value)

can be achieved efficiently by:

  (-> date (property :dayOfMonth) value)

saturday?

(saturday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a saturday.

seconds

(seconds o__1718__auto__)
Constructs a Seconds period representing the given number of seconds. Given a time entity tries to extract the number of seconds. Given another period, extracts its seconds part.

seconds-in

(seconds-in G__2194)(seconds-in x__2170__auto__ y__2171__auto__)
Number of seconds in the given period/interval/pair of
instants, date-times or partials. Also handles durations.

standard-period-type

Standard period type. Alias to `PeriodType/standard`.

start

(start i)
Gets the start of the interval.

sunday?

(sunday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a sunday.

thursday?

(thursday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a thursday.

timezone

(timezone)(timezone tz)
Produces a `DateTimeZone` out of a `java.util.TimeZone` or a timezone ID - a
case-sensitive string, keyword or symbol:

  (timezone :UTC)
  => #<FixedDateTimeZone UTC>

Default time zone is returned when called with no arguments:

  (timezone)
  => #<CachedDateTimeZone Europe/Vilnius>

to-java-date

(to-java-date o)
Converts (almost) anything to a `java.util.Date`. By
default conversion will happen in the default time zone,
i.e.:

  ; In +02:00 zone
  (to-java-date "2013-12-10")
  => #inst "2013-12-09T22:00:00.000-00:00"

  ; In UTC
  (to-java-date "2013-12-10")
  => #inst "2013-12-10T00:00:00.000-00:00"

to-millis-from-epoch

(to-millis-from-epoch o)

to-sql-date

(to-sql-date o)
Converts a date entity to a `java.sql.Date`.

to-sql-timestamp

(to-sql-timestamp o)

tuesday?

(tuesday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a tuesday.

value

(value p)
Value of this property.

wednesday?

(wednesday? o__2198__auto__)
Returns true if the given instant/date-time/partial with the
`dayOfWeek` property represents a wednesday.

weekday?

(weekday? dt)

weekend?

(weekend? dt)

weeks

(weeks o__1718__auto__)
Constructs a Weeks period representing the given number of weeks. Given a time entity tries to extract the number of weeks. Given another period, extracts its weeks part.

weeks-in

(weeks-in G__2186)(weeks-in x__2170__auto__ y__2171__auto__)
Number of weeks in the given period/interval/pair of
instants, date-times or partials.

with-max-value

(with-max-value p)
Instant, partial or a period with the value of the property set to the
`max-value`.

with-min-value

(with-min-value p)
Instant, partial or a period with the value of the property set to the
`min-value`.

with-value

(with-value p v)
Instant, partial or a period with the property set to the provided
value.

with-zone

(with-zone o zone)
Set the time zone for the given date-time or a formatter.
Argument `zone` might be a `DateTimeZone` or a (case-sensitive)
name of the time zone.

year-month

(year-month)(year-month o__1986__auto__)(year-month year month)
Constructs a YearMonth out of 

* another partial (which must have all of the needed fields)
* an instant or a number of milliseconds
* a java (util/sql) Date/Timestamp or a Calendar
* an ISO formatted string
* a map with keys corresponding to the names of date-time field types
  and an (optional) chronology.
* a number of ints for the multi-argument varieties of partial constructors.

When called with no arguments produces a value of `YearMonth/now`.

years

(years o__1718__auto__)
Constructs a Years period representing the given number of years. Given a time entity tries to extract the number of years. Given another period, extracts its years part.

years-in

(years-in G__2182)(years-in x__2170__auto__ y__2171__auto__)
Number of years in the given period/interval/pair of
instants, date-times or partials.