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.
(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.
(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.
(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.
(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.
(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.
(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.
(days n)
Returns a Period representing the given number of days.
Returns a Period representing the given number of days.
(default-time-zone)
(end in)
Returns the end DateTime of an Interval.
Returns the end DateTime of an Interval.
(epoch)
(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
(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.
(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.
(hours n)
Returns a Period representing the given number of hours.
Returns a Period representing the given number of hours.
(in-minutes in)
Returns the number of standard minutes in the given Interval.
Returns the number of standard minutes in the given Interval.
(in-msecs in)
Returns the number of standard seconds in the given Interval.
Returns the number of standard seconds in the given Interval.
(in-secs in)
Returns the number of standard seconds in the given Interval.
Returns the number of standard seconds in the given Interval.
(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.
(milli dt)
Return the millisecond-of-second component of the given DateTime.
Return the millisecond-of-second component of the given DateTime.
(millis n)
Returns a Period representing the given number of milliseconds.
Returns a Period representing the given number of milliseconds.
(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).
(minute dt)
Return the minute of hour component of the given DateTime.
Return the minute of hour component of the given DateTime.
(minutes n)
Returns a Period representing the given number of minutes.
Returns a Period representing the given number of minutes.
(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.
(months n)
Returns a Period representing the given number of months.
Returns a Period representing the given number of months.
(now)
(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?
(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).
(sec dt)
Return the second-of-minute component of the given DateTime.
Return the second-of-minute component of the given DateTime.
(secs n)
Returns a Period representing the given number of seconds.
Returns a Period representing the given number of seconds.
(start in)
Returns the start DateTime of an Interval.
Returns the start DateTime of an Interval.
(time-zone-for-id id)
(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.
(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.
(weeks n)
Returns a Period representing the given number of weeks.
Returns a Period representing the given number of weeks.
(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.
(year dt)
Return the year component of the given DateTime.
Return the year component of the given DateTime.
(years n)
Returns a Period representing the given number of years.
Returns a Period representing the given number of years.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close