Liking cljdoc? Tell your friends :D

clj-time.core

The core namespace for date-time operations in the clj-time library.

Create a DateTime instance with date-time, specifying the year, month, day, hour, minute, second, and millisecond:

=> (date-time 1986 10 14 4 3 27 456) #<DateTime 1986-10-14T04:03:27.456Z>

Less-significant fields can be omitted:

=> (date-time 1986 10 14) #<DateTime 1986-10-14T00:00:00.000Z>

Get the current time with (now) and the start of the Unix epoch with (epoch).

Once you have a date-time, use accessors like hour and sec to access the corresponding fields:

=> (hour (date-time 1986 10 14 22)) 22

The date-time constructor always returns times in the UTC time zone. If you want a time with the specified fields in a different time zone, use from-time-zone:

=> (from-time-zone (date-time 1986 10 22) (time-zone-for-offset -2)) #<DateTime 1986-10-22T00:00:00.000-02:00>

If on the other hand you want a given absolute instant in time in a different time zone, use to-time-zone:

=> (to-time-zone (date-time 1986 10 22) (time-zone-for-offset -2)) #<DateTime 1986-10-21T22:00:00.000-02:00>

In addition to time-zone-for-offset, you can use the time-zone-for-id and default-time-zone functions and the utc Var to constgruct or get DateTimeZone instances.

The functions after? and before? determine the relative position of two DateTime instances:

=> (after? (date-time 1986 10) (date-time 1986 9)) true

Often you will want to find a date some amount of time from a given date. For example, to find the time 1 month and 3 weeks from a given date-time:

=> (plus (date-time 1986 10 14) (months 1) (weeks 3)) #<DateTime 1986-12-05T00:00:00.000Z>

An Interval is used to represent the span of time between two DateTime instances. Construct one using interval, then query them using within?, overlaps?, and abuts?

=> (within? (interval (date-time 1986) (date-time 1990)) (date-time 1987)) true

To find the amount of time encompased by an interval, use in-secs and in-minutes:

=> (in-minutes (interval (date-time 1986 10 2) (date-time 1986 10 14))) 17280

Note that all functions in this namespace work with Joda objects or ints. If you need to print or parse date-times, see clj-time.format. If you need to ceorce date-times to or from other types, see clj-time.coerce.

The core namespace for date-time operations in the clj-time library.

Create a DateTime instance with date-time, specifying the year, month, day,
hour, minute, second, and millisecond:

  => (date-time 1986 10 14 4 3 27 456)
  #<DateTime 1986-10-14T04:03:27.456Z>

Less-significant fields can be omitted:

  => (date-time 1986 10 14)
  #<DateTime 1986-10-14T00:00:00.000Z>

Get the current time with (now) and the start of the Unix epoch with (epoch).

Once you have a date-time, use accessors like hour and sec to access the
corresponding fields:

  => (hour (date-time 1986 10 14 22))
  22

The date-time constructor always returns times in the UTC time zone. If you
want a time with the specified fields in a different time zone, use
from-time-zone:

  => (from-time-zone (date-time 1986 10 22) (time-zone-for-offset -2))
  #<DateTime 1986-10-22T00:00:00.000-02:00>

If on the other hand you want a given absolute instant in time in a
different time zone, use to-time-zone:

  => (to-time-zone (date-time 1986 10 22) (time-zone-for-offset -2))
  #<DateTime 1986-10-21T22:00:00.000-02:00>

In addition to time-zone-for-offset, you can use the time-zone-for-id and
default-time-zone functions and the utc Var to constgruct or get DateTimeZone
instances.

The functions after? and before? determine the relative position of two
DateTime instances:

  => (after? (date-time 1986 10) (date-time 1986 9))
  true

Often you will want to find a date some amount of time from a given date. For
example, to find the time 1 month and 3 weeks from a given date-time:

  => (plus (date-time 1986 10 14) (months 1) (weeks 3))
  #<DateTime 1986-12-05T00:00:00.000Z>

An Interval is used to represent the span of time between two DateTime
instances. Construct one using interval, then query them using within?,
overlaps?, and abuts?

  => (within? (interval (date-time 1986) (date-time 1990))
              (date-time 1987))
  true

To find the amount of time encompased by an interval, use in-secs and
in-minutes:

  => (in-minutes (interval (date-time 1986 10 2) (date-time 1986 10 14)))
  17280

Note that all functions in this namespace work with Joda objects or ints. If
you need to print or parse date-times, see clj-time.format. If you need to
ceorce date-times to or from other types, see clj-time.coerce.
raw docstring

abuts?clj

(abuts? i-a i-b)

Returns true if Interval i-a abuts i-b, i.e. then end of i-a is exactly the beginning of i-b.

Returns true if Interval i-a abuts i-b, i.e. then end of i-a is exactly the
beginning of i-b.
raw docstring

after?clj

(after? dt-a dt-b)

Returns true if DateTime dt-a is strictly after DateTime dt-b.

Returns true if DateTime dt-a is strictly after DateTime dt-b.
raw docstring

before?clj

(before? dt-a dt-b)

Returns true if DateTime dt-a is strictly before DateTime dt-b.

Returns true if DateTime dt-a is strictly before DateTime dt-b.
raw docstring

date-timeclj

(date-time year)
(date-time year month)
(date-time year month day)
(date-time year month day hour)
(date-time year month day hour minute)
(date-time year month day hour minute second)
(date-time year month day hour minute second millis)

Constructs and returns a new DateTime in UTC. Specify the year, month of year, day of month, hour of day, minute if hour, second of minute, and millisecond of second. Note that month and day are 1-indexed while hour, second, minute, and millis are 0-indexed. Any number of least-significant components can be ommited, in which case they will default to 1 or 0 as appropriate.

Constructs and returns a new DateTime in UTC.
Specify the year, month of year, day of month, hour of day, minute if hour,
second of minute, and millisecond of second. Note that month and day are
1-indexed while hour, second, minute, and millis are 0-indexed.
Any number of least-significant components can be ommited, in which case
they will default to 1 or 0 as appropriate.
raw docstring

dayclj

(day dt)

Return the day of month component of the given DateTime. Monday is 1 and Sunday is 7.

Return the day of month component of the given DateTime. Monday is 1 and
Sunday is 7.
raw docstring

day-of-weekclj

(day-of-week dt)

Return the day of month component of the given DateTime. Monday is 1 and Sunday is 7.

Return the day of month component of the given DateTime. Monday is 1 and
Sunday is 7.
raw docstring

daysclj

(days n)

Returns a Period representing the given number of days.

Returns a Period representing the given number of days.
raw docstring

default-time-zoneclj

(default-time-zone)

endclj

(end in)

Returns the end DateTime of an Interval.

Returns the end DateTime of an Interval.
raw docstring

epochclj

(epoch)

extendclj

(extend in & by)

Returns an Interval with an end DateTime the specified Period after the end of the given Interval

Returns an Interval with an end DateTime the specified Period after the end
of the given Interval
raw docstring

from-time-zoneclj

(from-time-zone dt tz)

Returns a new DateTime corresponding to the same point in calendar time as the given DateTime, but for a correspondingly different absolute instant in time.

Returns a new DateTime corresponding to the same point in calendar time as
the given DateTime, but for a correspondingly different absolute instant in
time.
raw docstring

hourclj

(hour dt)

Return the hour of day component of the given DateTime. A time of 12:01am will have an hour component of 0.

Return the hour of day component of the given DateTime. A time of 12:01am
will have an hour component of 0.
raw docstring

hoursclj

(hours n)

Returns a Period representing the given number of hours.

Returns a Period representing the given number of hours.
raw docstring

in-minutesclj

(in-minutes in)

Returns the number of standard minutes in the given Interval.

Returns the number of standard minutes in the given Interval.
raw docstring

in-msecsclj

(in-msecs in)

Returns the number of standard seconds in the given Interval.

Returns the number of standard seconds in the given Interval.
raw docstring

in-secsclj

(in-secs in)

Returns the number of standard seconds in the given Interval.

Returns the number of standard seconds in the given Interval.
raw docstring

intervalclj

(interval dt-a dt-b)

Returns an interval representing the span between the two given DateTimes. Note that intervals are closed on the left and open on the right.

Returns an interval representing the span between the two given DateTimes.
Note that intervals are closed on the left and open on the right.
raw docstring

milliclj

(milli dt)

Return the millisecond-of-second component of the given DateTime.

Return the millisecond-of-second component of the given DateTime.
raw docstring

millisclj

(millis n)

Returns a Period representing the given number of milliseconds.

Returns a Period representing the given number of milliseconds.
raw docstring

minusclj

(minus dt p)
(minus dt p & ps)

Returns a new DateTime corresponding to the given DateTime moved backwards by the given Period(s).

Returns a new DateTime corresponding to the given DateTime moved backwards by
the given Period(s).
raw docstring

minuteclj

(minute dt)

Return the minute of hour component of the given DateTime.

Return the minute of hour component of the given DateTime.
raw docstring

minutesclj

(minutes n)

Returns a Period representing the given number of minutes.

Returns a Period representing the given number of minutes.
raw docstring

monthclj

(month dt)

Return the month-of-year component of the given DateTime. January is 1.

Return the month-of-year component of the given DateTime. January is 1.
raw docstring

monthsclj

(months n)

Returns a Period representing the given number of months.

Returns a Period representing the given number of months.
raw docstring

nowclj

(now)

overlaps?clj

(overlaps? i-a i-b)

Returns true of the two given Intervals overlap. Note that intervals that satisfy abuts? do not satisfy overlaps?

Returns true of the two given Intervals overlap. Note that intervals that
satisfy abuts? do not satisfy overlaps?
raw docstring

plusclj

(plus dt p)
(plus dt p & ps)

Returns a new DateTime corresponding to the given DateTime moved forwards by the given Period(s).

Returns a new DateTime corresponding to the given DateTime moved forwards by
the given Period(s).
raw docstring

secclj

(sec dt)

Return the second-of-minute component of the given DateTime.

Return the second-of-minute component of the given DateTime.
raw docstring

secsclj

(secs n)

Returns a Period representing the given number of seconds.

Returns a Period representing the given number of seconds.
raw docstring

startclj

(start in)

Returns the start DateTime of an Interval.

Returns the start DateTime of an Interval.
raw docstring

time-zone-for-idclj

(time-zone-for-id id)

time-zone-for-offsetclj

(time-zone-for-offset hours)
(time-zone-for-offset hours minutes)

Returns a DateTimeZone for the given offset, specified either in hours or hours and minutes.

Returns a DateTimeZone for the given offset, specified either in hours or
hours and minutes.
raw docstring

to-time-zoneclj

(to-time-zone dt tz)

Returns a new DateTime corresponding to the same absolute instant in time as the given DateTime, but with calendar fields corresponding to the given TimeZone.

Returns a new DateTime corresponding to the same absolute instant in time as
the given DateTime, but with calendar fields corresponding to the given
TimeZone.
raw docstring

utcclj

DateTimeZone for UTC.

DateTimeZone for UTC.
raw docstring

weeksclj

(weeks n)

Returns a Period representing the given number of weeks.

Returns a Period representing the given number of weeks.
raw docstring

within?clj

(within? i dt)

Returns true if the given Interval contains the given DateTime. Note that if the DateTime is exactly equal to the end of the interval, this function returns false.

Returns true if the given Interval contains the given DateTime. Note that
if the DateTime is exactly equal to the end of the interval, this function
returns false.
raw docstring

yearclj

(year dt)

Return the year component of the given DateTime.

Return the year component of the given DateTime.
raw docstring

yearsclj

(years n)

Returns a Period representing the given number of years.

Returns a Period representing the given number of years.
raw docstring

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

× close