+ - Sum amounts of time:
(t/+ (t/new-duration 10 :hours)
(t/new-duration 10 :minutes))
This section gives, in alphabetical order, examples of how to use each function in the tick api library.
+ - Sum amounts of time:
(t/+ (t/new-duration 10 :hours)
(t/new-duration 10 :minutes))
- - Subtract amounts of time:
(t/- (t/new-duration 12 :hours)
(t/new-duration 10 :hours))
<< - Go back in time a duration:
(t/<< (t/now) (t/new-period 10 :weeks))
>> - Go forward in time a duration:
(t/>> (t/now) (t/new-duration 10 :hours))
< - Before?
(t/< (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00"))
> - After?
(t/> (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00"))
<= - Before or same time?
(t/<= (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00"))
>= - After or same time?
(t/>= (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00"))
ago - Give the time a duration ago:
(t/ago (t/new-duration 1 :hours))
am - Create an interval spanning the morning of a given date:
(t/am (t/date "2018-01-01"))
at - Make date-time from a date (given date at "time"):
(-> (t/date "2000-01-01") (t/at "00:00"))
atom - Create an holder for the current time:
(let [clk (t/atom)]
(t/time @clk))
beginning - Give the beginning of an interval:
(t/beginning (t/today))
between - Give a value for the duration between two instances:
(t/between (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00"))
bounds - Give the beginning and end of an interval:
(t/bounds (t/yesterday))
clock - Create a system clock or fixed clock:
(t/clock)
(t/clock (t/instant "2018-01-01T00:00"))
coincident? - Are two intervals the same?
(t/coincident? (t/today) (t/today))
complement - Give the inverse of a list of intervals.
(t/complement [(t/instant "2010-01-01T00:00")
(t/instant "2010-02-01T00:00")
(t/instant "2010-03-01T00:00")])
concur - Get the common interval (if any) of two intervals.
(t/concur (t/today) (t/new-interval (t/yesterday) (t/tomorrow)))
concurrencies - A sequence of times when intervals overlap:
(t/concurrencies (t/pm (t/today)) (t/new-interval (t/today) (t/tomorrow)))
conj - Return new collection with the original collection including a new date:
(t/conj [(t/yesterday) (t/today)] (t/tomorrow))
date - Get the date:
(t/date)
(t/date) (t/tomorrow)
(t/date (t/instant "2018-01-01T00:00"))
(t/date "2018-01-01")
date-time - Get the date-time:
(t/date-time)
(t/date-time (t/tomorrow))
(t/date-time (t/instant "2018-01-01T00:00"))
(t/date "2018-01-01T00:00")
day-of-month - Get the numerical day of the month:
(t/day-of-month)
(t/day-of-month "2018-01-01")
(t/day-of-month (t/tomorrow))
(t/day-of-month (t/instant "2018-01-01T00:00"))
day-of-week - Get the day of the week
(t/day-of-week)
(t/day-of-week (t/yesterday))
(t/day-of-week (t/instant "2018-01-01T00:00"))
(t/day-of-week "2018-01-01")
days - Convert a duration into days
(t/days (t/new-duration 24 :hours))
dec - Give the previous year:
(t/dec (t/year))
difference - Return the first collection without the second collection elements.
(t/difference [(t/yesterday) (t/today) (t/tomorrow)] [(t/today)])
divide - Divide a duration by another duration:
(t/divide (t/new-duration 1 :days) (t/new-duration 1 :hours))
divide-by - Split an interval into even sections of time:
(t/divide-by 10 {:tick/beginning (t/instant "2018-01-01T00:00")
:tick/end (t/instant "2018-01-10T00:00")})
duration - Give the duration of an interval:
(t/duration {:tick/beginning (t/instant "2018-01-01T00:00")
:tick/end (t/instant "2018-01-10T00:00")})
end - Give the end instance of an interval:
(t/end {:tick/beginning (t/instant "2018-01-01T00:00")
:tick/end (t/instant "2018-01-10T00:00")})
epoch - Give the epoch:
(t/epoch)
extend - Extend an interval by a duration:
(t/extend {:tick/beginning (t/instant "2018-01-01T00:00")
:tick/end (t/instant "2018-01-10T00:00")}
(t/new-period 10 :weeks))
fields - Get the field for a given time value:
(t/fields (t/time))
group-by - Group a collection of intervals by a given function.
(t/group-by t/year
(map #(apply t/new-interval %)
(t/divide-by (t/new-duration 1 :days)
(t/new-interval (t/new-date 2000 12 29)
(t/new-date 2001 1 2)))))
hence - Return an instant 15 minutes from now:
(t/hence (t/new-duration 15 :minutes))
hour - Give the hour of the day:
(t/hour (t/now))
hours - Give a duration in hours:
(t/hours (t/new-duration 2 :days))
in - Give an instance in a time zone:
(t/in (t/instant "2018-01-01T10:00") "Australia/Darwin")
inc - Give the next year:
(t/inc (t/year))
inst - Convert to java.util.Date:
(t/inst)
(t/inst (t/instant "2018-01-01T00:00"))
instant - Convert to java.time.Instant:
(t/instant (t/inst))
(t/instant "2018-01-01T00:00:00.000+09:30[Australia/Darwin]")
int - Give the year as an integer:
(t/int (t/year))
intersection - Give the intersection of two sequences:
(t/intersection [(t/year)]
[(t/date "2019-01-01")
(t/date "2020-01-01")
(t/date "2021-01-01")])
intersects? - Does an interval intersect with another? Return nil if not, or the intersection if so.
(t/intersects? [(t/year)]
(t/inc (t/year)))
(t/intersects? [(t/year)]
(t/today))
long - return an instant as a long:
(t/long (t/instant))
max - Give the last chronological date from multiple unordered dates:
(t/max (t/today) (t/tomorrow) (t/yesterday) (t/new-date 2018 11 11))
micros - Give a duration in microseconds:
(t/micros (t/new-duration 5 :minutes))
microsecond - Give the microsecond of an instant:
(t/microsecond (t/now))
midnight - Time at midnight:
(t/midnight)
midnight? - Is it midnight?
(t/midnight? (t/date-time))
millis - Give a duration in milliseconds:
(t/millis (t/new-duration 5 :minutes))
millisecond - Give the millisecond of an instant.
(t/millisecond (t/now))
min - Give the first chronological date from an unordered list of dates:
(t/min (t/today) (t/tomorrow) (t/yesterday) (t/new-date 2018 11 11))
minutes - Give a duration in minutes:
(t/minutes (t/new-duration 5 :hours))
minute - Give the minute of an instant:
(t/minute (t/now))
month - Get the month:
(t/month)
(t/month "2018-11-11")
months - Get the number of months in a duration:
(t/months (t/new-period 10 :months))
nanos - Get the number of nanoseconds in a duration:
(t/nanos (t/new-duration 5 :minutes))
nanosecond - Get the nanosecond of the time:
(t/nanosecond (t/now))
new-date - Created a new java.time.LocalDate
(t/new-date 2000 01 01)
(t/new-date)
t/new-duration - Create a new duration.
(t/new-duration 10 :minutes)
new-duration units are from nanos to days. For larger units of time, see new-period.
|
new-interval - Create a new interval: a map with a :tick/beginning and a :tick/end
(t/new-interval (t/instant "2018-01-01T00:00") (t/instant "2019-01-01T00:00"))
new-period - Create a new duration:
(t/new-period 10 :weeks)
new period is in units greater than days. For smaller units,
see new-duration.
|
new-time - Create a new java.time.LocalTime
(t/new-time)
(t/new-time 12 00)
noon - Give the time at noon.
(t/noon)
normalize - From a time ordered sequence of disjointed intervals, return a
sequence of interval groups:
(count (t/normalize [(t/new-interval (t/instant "2000-01-01T00:00")
(t/instant "2000-01-02T00:00"))
(t/new-interval (t/instant "2000-01-02T00:00")
(t/instant "2000-02-02T00:00"))
(t/new-interval (t/instant "2000-06-01T00:00")
(t/instant "2000-06-09T00:00"))]))
now - Give now as an instant:
(t/now)
offset-by - Give a java.time.OffsetDateTime of a specified instant with a
specified offset:
(t/offset-by (t/now) 1)
offset-date-time - Convert a java.time.Instant to a java.time.OffsetDateTime
(t/offset-date-time (t/zoned-date-time "2000-01-01T00:00:00Z[Australia/Darwin]"))
(t/offset-date-time)
on - Give a LocalDateTime for a given time on a given date:
(t/on (t/new-time 11 00) (t/new-date 2000 01 01))
ordered-disjoint-intervals? - Are the given intervals time-ordered and disjointed?
(t/ordered-disjoint-intervals? [(t/new-interval (t/instant "2000-01-01T00:00")
(t/instant "2000-01-02T00:00"))
(t/new-interval (t/instant "2000-01-02T00:00")
(t/instant "2000-02-02T00:00"))])
parse - Give the most applicable instance for the input string:
(t/parse "1pm")
pm - Give an interval covering the afternoon of a given date:
(t/pm (t/today))
range - Give a lazy sequence of times from start to finish.
(t/range (t/date-time "2000-01-01T12:00")
(t/date-time "2000-01-01T12:05")
(t/new-duration 1 :minutes))
relation - Show the relation of two intervals:
(t/relation {:tick/beginning (t/instant "2018-01-01T00:00")
:tick/end (t/instant "2019-01-01T00:00")}
{:tick/beginning (t/instant "2018-06-01T00:00")
:tick/end (t/instant "2019-06-01T00:00")})
(t/relation (t/today) (t/yesterday))
| see above for more. |
reset! - Reset an atom clock with one 5 mins slow.
(let [clk (t/atom)
clk2 (t/atom (t/<< (t/clock) (t/new-duration 5 :minutes)))]
(t/reset! clk clk2))
reset-vals! - Reset an atom clock with one 5 mins slow, and give the
value of before and after.
(let [clk (t/atom)
clk2 (t/atom (t/<< (t/clock) (t/new-duration 5 :minutes)))]
(t/reset-vals! clk clk2))
scale - Increase an interval by a given duration:
(t/scale {:tick/beginning (t/instant "2018-01-01T00:00")
:tick/end (t/instant "2019-01-01T00:00")}
(t/new-duration 10 :minutes))
seconds - Give a duration in seconds:
(t/seconds (t/new-duration 5 :minutes))
second - Give the second of time:
(t/second (t/now))
time - Give the time of an instant:
(t/time (t/now))
today - Give todays date:
(t/today)
tomorrow - Give tomorrows date:
(t/tomorrow)
truncate - Lessen precision of an instant:
(t/truncate (t/instant) :days)
union - Join two time-ordered sequences together into one ordered sequence
(t/union [(t/today)] [(t/yesterday) (t/tomorrow)])
unit-map - A map of units of time that tick works with:
(keys t/unit-map)
(:minutes t/unit-map)
unite - Unite concurrent intervals ordered by beginning:
(t/unite [(t/new-interval (t/instant "2000-01-01T00:00")
(t/instant "2000-01-02T00:00"))
(t/new-interval (t/instant "2000-01-01T00:00")
(t/instant "2000-02-02T00:00"))])
units - Give the appropriate units for a duration:
(t/units (t/new-duration 1000000001 :nanos))
with - Return a date with an altered field:
(t/with (t/today) :day-of-month 1)
with-clock - Get the time from a clock:
(let [clk (t/>> (t/clock) (t/new-duration 5 :minutes))]
(t/with-clock clk (t/time)))
year - Give the year:
(t/year)
(t/year "2000-01-01")
year-month - Give the year and month:
(t/year-month)
(t/year-month "2000-01-01")
years - Give a duration in years.
(t/years (t/new-period 10 :years))
yesterday - Give yesterdays date:
(t/yesterday)
zone - Give the time zone:
(t/zone)
(t/zone (t/zoned-date-time "2000-01-01T00:00:00Z[Australia/Darwin]"))
zone-offset - Give the java.time.ZoneOffset with a specified offset:
(t/zone-offset 1 30 59)
zoned-date-time - Create a java.time.ZonedDateTime:
(t/zoned-date-time)
(t/zoned-date-time "2000-01-01T00:00:00Z[Australia/Darwin]")
Can you improve this documentation? These fine people already did:
Henry Widd, Bruce Durling, Johanna Antonelli, Johantonelli, Caro & Malcolm SparksEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |