juxt.pro - tick









Search Preview

tick

juxt.pro
☰ Services Home Delivery Training Compliance
.pro > juxt.pro

SEO audit: Content analysis

Language Error! No language localisation is found.
Title tick
Text / HTML ratio 48 %
Frame Excellent! The website does not use iFrame solutions.
Flash Excellent! The website does not have any flash contents.
Keywords cloud time tinstant date duration Give tick tnewduration instant interval minutes dates tdate clock ttime days day tnow hours tnewperiod ttoday
Keywords consistency
Keyword Content Title Description Headings
time 124
tinstant 69
date 51
duration 49
Give 45
tick 42
Headings
H1 H2 H3 H4 H5 H6
1 12 42 20 1 0
Images We found 0 images on this web page.

SEO Keywords (Single)

Keyword Occurrence Density
time 124 6.20 %
tinstant 69 3.45 %
date 51 2.55 %
duration 49 2.45 %
Give 45 2.25 %
tick 42 2.10 %
tnewduration 41 2.05 %
instant 41 2.05 %
interval 38 1.90 %
minutes 33 1.65 %
dates 30 1.50 %
tdate 27 1.35 %
clock 27 1.35 %
ttime 26 1.30 %
days 24 1.20 %
day 24 1.20 %
tnow 23 1.15 %
hours 21 1.05 %
tnewperiod 20 1.00 %
ttoday 20 1.00 %

SEO Keywords (Two Word)

Keyword Occurrence Density
Give the 28 1.40 %
of the 27 1.35 %
an instant 26 1.30 %
the time 25 1.25 %
can be 23 1.15 %
an interval 21 1.05 %
a duration 21 1.05 %
Get the 20 1.00 %
tinstant 20180101T0000 20 1.00 %
the current 19 0.95 %
of time 16 0.80 %
we can 16 0.80 %
tnewduration 5 15 0.75 %
the date 13 0.65 %
is a 13 0.65 %
a specific 12 0.60 %
tnewduration 1 12 0.60 %
a given 12 0.60 %
tickbeginning tinstant 12 0.60 %
get the 12 0.60 %

SEO Keywords (Three Word)

Keyword Occurrence Density Possible Spam
the current time 10 0.50 % No
tnewduration 5 minutes 8 0.40 % No
tickbeginning tinstant 20180101T0000 8 0.40 % No
tinstant 20180101T0000 tickend 8 0.40 % No
20180101T0000 tickend tinstant 8 0.40 % No
units of time 7 0.35 % No
get the current 7 0.35 % No
To get the 7 0.35 % No
tnewduration 1 hours 6 0.30 % No
Give a duration 6 0.30 % No
tnewperiod 10 weeks 6 0.30 % No
a duration in 6 0.30 % No
tickend tinstant 20180110T0000 6 0.30 % No
of an interval 6 0.30 % No
we can use 6 0.30 % No
20000101T0000 tinstant 20180101T0000 5 0.25 % No
of an instant 5 0.25 % No
Description Return type 5 0.25 % No
shown in Example 5 0.25 % No
tinstant 20000101T0000 tinstant 5 0.25 % No

SEO Keywords (Four Word)

Keyword Occurrence Density Possible Spam
tinstant 20180101T0000 tickend tinstant 8 0.40 % No
tickbeginning tinstant 20180101T0000 tickend 8 0.40 % No
Give a duration in 6 0.30 % No
20180101T0000 tickend tinstant 20180110T0000 6 0.30 % No
To get the current 6 0.30 % No
as shown in Example 5 0.25 % No
tinstant 20000101T0000 tinstant 20180101T0000 5 0.25 % No
t tdate 20000101 tnewperiod 4 0.20 % No
and <= tdays duration 4 0.20 % No
duration 1 format d 4 0.20 % No
Code Description Return type 4 0.20 % No
tinstant 20000101T0000 tickend tinstant 3 0.15 % No
tickbeginning tinstant 20000101T0000 tickend 3 0.15 % No
20000101T0000 tickend tinstant 20000102T0000 3 0.15 % No
let if tick< tickinstant 3 0.15 % No
duration to an instant 3 0.15 % No
Getting a specific datetime 3 0.15 % No
tnewdate 2000 01 01 3 0.15 % No
tbounds tyear 2000 tnewperiod 3 0.15 % No
tnewduration 1 hours tnewduration 3 0.15 % No

Internal links in - juxt.pro

Home
JUXT: Delivering Innovation
Delivery
JUXT: How We Deliver
Training
JUXT: JUXT Training Courses
Compliance
JUXT: Compliance
Blog
JUXT: The JUXT Blog
Why JUXT?
JUXT: Why JUXT?
Why Clojure?
JUXT: Why Clojure?
Clojure In
JUXT: Clojure In - Reference Clojure case studies from across Europe
Tech Radar
JUXT: Radar
Library
JUXT: Delivering Innovation
edge
The Edge Manual
tick
tick
yada
The yada manual
About Us
JUXT: About Us
Clients
JUXT: Clients
Team
JUXT: JUXTers
Careers
JUXT: Join JUXT
Community
JUXT: Community
Contact
JUXT: Contact
OnTheMarket.com and JUXT
JUXT: Blog: OnTheMarket.com and JUXT
Trading Dashboards for Tier-One Banking
JUXT: Blog: Trading Dashboards for Tier-One Banking
Building a Bitemporal Data-Store
JUXT: Blog: Building a Bitemporal Data-Store
Deploying libraries with deps.edn
JUXT: Blog: Deploying libraries with deps.edn
Testable Clojurescript apps
JUXT: Blog: Testable Clojurescript apps
Just a techie?
JUXT: Blog: Just a techie?
Login
JUXT:

Juxt.pro Spined HTML


tick ☰ Services Home Delivery Training Compliance Resources Blog Why JUXT? Why Clojure? Clojure In Tech Radar Library Tech crux whet tick yadaWell-nighAbout Us Clients Team Careers Community Contact tick Malcolm Sparks mal@juxt.pro Henry Widd Johanna Antonelli joa@juxt.pro version 0.4.5-alpha, 2018-10-10 Table of Contents 1. Introduction 1.1. Status 1.2. License 1.3. Comparison to other time libraries Java 8 time clj-time and cljs-time Quartz 2. Setup 2.1. Serialization 2.2. Clojurescript Shadow-CLJS Dropping to java.time Timezones Formatting Why are the uneaten requires needed? OffsetTime and OffsetDateTime 3. API 4. Times & dates 4.1. Introduction 4.2. Construction 4.3. Reification 4.4. Conversion 4.5. Extraction 4.6. Comparison 4.7. Modification 4.8. Truncation 5. Durations & periods 5.1. Construction Days, Months, Years… 5.2. Derivation 5.3. Comparison 5.4. Misc 6. Clocks 6.1. Construction 6.2. Derivation 6.3. Comparison 6.4. Atomic clocks? 6.5. Substitution 7. Intervals 7.1. Construction 7.2. Derivation 7.3. Comparison 7.4. Collections 7.5. Demonstration 8. Calendars 8.1. Construction 8.2. Derivation 8.3. Comparison 9. Schedules 9.1. Construction 9.2. Derivation 9.3. Comparison 10. Formatting 11. Cookbook 11.1. Introduction 11.2. Times & dates Create time Get the time Create a stage Get the stage Build up times and dates Time andStagemanipulation 11.3. Instants and Inst Creation Conversions between Inst and Instant 11.4. Time Zones & Offset 11.5. Intervals Create an interval Interval Manipulation: 11.6. Arithmetic Simple maths 11.7.Warm-uptimers 11.8. Miscellaneous 11.9. Tick Reference References 1. Introduction Time is an illusion. Lunchtime doubly so. — Douglas Adams The Hitchhiker's Guide to the Galaxy Tick is a comprehensive Clojure(Script) library designed to make it easier to write programs that involve time and stage calculations: Functions to manipulating time, hands and succinctly (stable) Powerful functions for slicing and dicing time intervals (stable) Implementation of Allen’s interval algebra (stable) Support for iCalendar serialization (work-in-progress) Scheduling (work-in-progress) In many merchantry domains, dates are as fundamental as numbers and strings. It’s often desirable to have date-heavy merchantry logic portable wideness platforms. Tick supports both Clojure and ClojureScript, with an identical API. 1.1. Status Tick is currently in start status. By alpha, we midpoint that the library’s API may transpiration in future. The quality of tick is deemed unobjectionable for real-world use but do let us know if you come wideness any unexpected behaviour and bugs. 1.2. License Tick is copyrighted by JUXT LTD. and licensed as self-ruling software under the open-source MIT License. The MIT License (MIT) Copyright © 2016-2018 JUXT LTD. Permission is hereby granted, self-ruling of charge, to any person obtaining a reprinting of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the pursuit conditions: The whilom copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1.3. Comparison to other time libraries Java 8 time Java 8’s java.time API is both influenced by, and an resurgence on, Joda Time. Unlike older JDK dates and calendars, instances in java.time are immutable so can be considered values in Clojure. For this reason, there is no reason to wrap these values. Consequently, there is full interoperability between tick and java.time. Where tick does not provide a part of java.time’s functionality, java.time can be tabbed directly. CautionConsideringtick is built on java.time, Clojure programs must run on Java 8 or higher. clj-time and cljs-time Most Clojure applications use clj-time which is based on Joda Time. However, cljs-time is a wrapper over goog.date which in turn is a wrapper over mutable JavaScriptStageobjects. This works OK as a proxy for Instant, but is not a unconfined foundation for local dates etc. The tragedian of cljs-time, Andrew McVeigh, has said he would ideally move cljs-time off goog.date but is unlikely to do so at this point. For one thing, there could be increasingly than a few current users relying on the JSStagenature of the cljs-time objects. Taking a fresh squint at the date/time landscape, we now have JSR-310 and implementations in both Java and Javascript and so it is possible to create tick, which combines the spanking-new JSR-310 with an expressive, cross-platform Clojure(Script) API. For some use cases it is possible to write cross-platform lawmaking with clj/s-time, conditionally requiring clj-time or cljs-time in a cljc file. In our wits though, the fact that cljs-time doesn’t have well-constructed fidelity with clj-time often comes to be a problem. Quartz See https://dzone.com/articles/why-you-shouldnt-use-quartz 2. Setup Get the latest from Clojars and add to your project.clj, build.boot or deps.edn. To use tick with Shadow-CLJS, there are some uneaten steps 2.1. Serialization There are many use cases for de/serialization of dates, including simply stuff worldly-wise to reprinting and paste within the REPL. Tick bundles jsr310-tagged-literals Clojure(Script) library, so having require’d tick, in your lawmaking or at the repl you can type #jsr310/period "P1D" which is read as a java.time.Period (or js-joda Period in ClojureScript). To read and write edn data containing these literals in Clojure(Script) and for increasingly information generally, see the tagged literals Readme 2.2. Clojurescript There are uneaten considerations when using tick with Clojurescript Shadow-CLJS TL;DR to use tick on shadow, follow this demo Tick uses an npm lib, js-joda which is packaged in cljsjs. Shadow ignores the :foreign-libs directive in the deps.cljs dependency file of that lib, so requires a shim to create the namespace that would normally come from the foreign-lib directive. In future, tick could instead require consumers to rely on :npm-deps directive in deps.cljs. Dropping to java.time Tick doesn’t contain equivalents of every method in java.time (of there are well-nigh ~2.5k in total), but that’s ok considering you can use interop syntax. However, Clojurescript does not support Clojure’s static method undeniability syntax. For example (java.time.Period/parse "P1D") Is valid Clojure, but not valid Clojurescript. However, using the 'dot' syntax, it is possible to write this so that it works in both Clojure and Clojurescript: (. java.time.Period parse "P1D") Property wangle is flipside problem, considering Clojurescript properties are prefixed with a '-'. For example to wangle property bar on foo: (.-bar foo) To get virtually this problem, there is a macro tick.interop/static-prop Timezones If you want to work with timezones, something like this, for example: (tick/zone "Europe/London") add the pursuit require: [tick.timezone] Formatting If you want to create custom formatters from patterns, such as "dd MMM yyyy", add this require: [tick.locale-en-us] Why are the uneaten requires needed? It is washed-up to indulge a smaller payload, when the uneaten libraries are not stuff used. Minified, gzipped js-joda (what gets pulled in if you use anything of tick) is virtually 43k. Timezone is an uneaten 26k, and Locale (just en-US) is an uneaten 45k Tick uses the js-joda library, which aims to replicate the three-ten-backport project. JS-Joda is wrenched lanugo into a cadre project (what tick depends on) and spare timezone and locale projects. The js-joda timezone dependency contains the timezone database, containing mappings between zone names, their offsets from UTC, and daylight savings(DST) data. Locale data is needed for custom stage formatters which need particular symbols, such as M for month. Due to the size and complexity of using the js-joda-locale, the authors of js-joda-locale have created prebuilt locale packages, for specific locales. en-US is one which is currently packaged for cljs and can be used as suggested above. OffsetTime and OffsetDateTime OffsetTime is currently missing from JS-Joda (see JS-Joda issue 240). For now, tick uses LocalTime as the implementation which is not ideal. OffsetDateTime is moreover missing but ZonedDateTime has the same functionality so this shouldn’t be a problem. 3. API Tick provides a single namespace—tick.api—containing the functions that make up the library’s API. When you are using tick in programs, it is a recommended idiom that you require tick's api under the t plume as follows: (require '[tick.alpha.api :as t]) Caution Try to restrict your use of tick to the tick.api namespace. Functions in other namespaces, which may not be marked private, are not part of the official API and could change. 4. Times & dates In this installment we introduce times & dates and how we can manipulate them. 4.1. Introduction If we asked a stranger for the time they’d likely respond with the just time of day, for example, "a quarter to eight". It would be uncommon for them to tell you the stage and timezone also, unless you asked for it. This is the same time that we learn to read as children, on analog watches and wall-clocks. So let’s start with asking tick for the time of day, with the time function. We demonstate this with our first example: Example 1. Getting the time To get the current time, undeniability (t/time) with no arguments: (t/time) Note If you have enabled JavaScript, you’ll see a sawed-off labelled Eval on the right of the lawmaking snippet. Press this sawed-off to instruct your browser to evaluate the tick lawmaking and exhibit the result. You can well-spoken the result by pressing the sawed-off labelled Clr. Many of the lawmaking examples in this documentation can be evaluated like this. But so we can protract with our time-telling story, let’s get a specific time of "a quarter to eight": Example 2. Getting a specific time To get a specific time of day, undeniability (t/time) with a string argument: (t/time "19:45") If we wanted to know the name of the day today, we might ask "what’s the day today". In tick, we’d use the day function. Example 3. Getting the name of the day We can get the name of the day today like this: (t/day-of-week (t/today)) Or, plane just: (t/day-of-week) Or, the day tomorrow: (t/day-of-week (t/tomorrow)) The time "a-quarter-to-eight tomorrow" is useful, but if we wanted to record events we’d soon want to ask the stage too. In tick, dates are specific timetable dates in the Gregorian timetable and include a day, month and year. We can ask the stage with the stage function: Example 4. Getting today’s stage To get today’s date, we use the stage function without arguments: (t/date) Alternatively we can undeniability today: (t/today) Note On the Java platform a tick stage corresponds to a java.time.LocalDate instance, while in a JavaScript environment it corresponds to js-joda’s LocalDate. Like with time, we can get particular dates by calling stage with a string argument: Example 5. Getting a specific stage To get June 21st (or 21st June! [1]) in 2018: (t/date "2018-06-21") Now we can ask for both time and date, we can combine them into a date-time. We can use the function date-time with no arguments to get the current time at the current date: Example 6. Getting the current date-time To get the current date-time, undeniability t/date-time with no arguments: (t/date-time) As with time and date, we can use a string treatise with date-time, as shown in Example 7. Example 7. Getting a specific date-time To get the time of the Armistice of Compiègne, use ISO 8601: (t/date-time "1918-11-11T11:00") A date-time is the time at a specific location on a specific timetable date. Since noon is established as the point at which the Sun crosses the meridian, and since the Earth is spherical and rotating, noon is the same time for everyone. Consequently, the world is split into time-zones, each at an offset to Coordinated Universal Time (UTC). If we wish to compare times in variegated places, we need to capture the local offset, as shown in Example 8. Example 8. Getting a specific date-time with a local offset. The Armistice of Compiègne was well-set at 11:00 am Paris time. On November 11th, 1918, Paris was one hour superiority of UTC. To capture this offset we can use offset-date-time: (t/offset-date-time "1918-11-11T11:00:00+01:00") There is a problem with using time offsets—they can transpiration for a given time zone, expressly since many time zones practice Daylight Savings Time (DST). To capture the very time zone, rather than the offset in effect on a given date, we can use zoned-date-time, as shown in Example 9. Why not local-date? Java and js-joda name classes representing dates and date-times with a prefix of 'Local'. Why doesn’t tick maintain this convention? The reason is that date-times (and dates especially) are unchangingly local, so the use of this prefix is superfluous. However, in Java, it is useful to distinguish between java.time.LocalDate and java.util.Date, or in JavaScript, between js-joda’s LocalDate and JavaScript’s seated Date. In these contexts, the 'Local' prefix makes sense. In, tick, instances of Java’s java.util.Date and JavaScript’sStageare termed insts, so the term stage is unambiguous (i.e. unchangingly local). Example 9. Getting a specific date-time in a time zone. The Armistice of Compiègne was well-set at 11:00 am Paris time. In the summer, Paris time moves one hour forward for Daylight Savings Time (DST). Although Paris did use Daylight Savings Time in 1918, the clocks had once moved when (at midnight on 8th October). To capture the time zone, withal with its various rules for gingerly offsets, we can use zoned-date-time: (t/zoned-date-time "1918-11-11T11:00:00Z[Europe/Paris]") Rather than using offset-date-times and zoned-date-times, you should use instants when you want UTC-based date-times and don’t superintendency well-nigh time-zones and 'local' time. Since a zoned-date-time (and offset-date-time) captures the offset from UTC, we can convert these into instants, as show in Example 10. Note On the Java platform, an instant is a java.time.Instant and replaces the flawed java.util.Date. In a JavaScript environment, js-joda provides an identical class. Example 10. Converting an offset-date-time to an instant To convert an offset-date-time to an instant, undeniability instant: For example: (t/instant (t/offset-date-time "1918-11-11T11:00:00+01:00")) If you want to get an instant representing the current time in UTC, undeniability instant without arguments. Example 11. Get the current instant in UTC To get the current instant, do this: (t/instant) Alternatively, you can just undeniability now: (t/now) If you do need a java.util.Date or JavaScript Date, for instance, for interoperating with an existing library, use the inst function. Example 12. Converting an instant to an inst To convert the current instant to an inst: (t/inst (t/now)) In this case, the same could be achieved with the zero-argument form of inst: (t/inst) That’s it for our introduction. Now we’ll return to constructing times and dates. 4.2. Construction Time values are synthetic with new-time. Example 13. Creating a time value To create the time 11 o’clock am: (t/new-time 11 0) new-time moreover has other forms to increase precision, for example, with seconds… (t/new-time 23 59 59) …and with nanoseconds (t/new-time 23 59 59 999999) What’s the difference between time and new-time? Until now we’ve been using time to create time values, for example, (t/time "11:00"), but now we have started to use the new-time function. What’s going on? Values are created using constructor functions in tick. There are moreover conversion functions, which are named without the value they convert to. For example, the time function is a conversion function which converts are string to a time value. In tick, the names of constructor functions are prefixed with new- to prevent naming clashes with conversion functions. These conventions have been taken from a blog vendible from Stuart Sierra on how to name Clojure functions—as good a guide as any. Similarly, dates are synthetic with new-date, a function which has 3 forms. The first, and most worldwide form, requires 3 arguments: the year, month and day (of the month). Example 14. Creating a stage value JUXT was incorporated on March 22nd, 2013. We can create this stage with new-date like this: (t/new-date 2013 3 22) 4.3. Reification While t/time and t/new-time return a time, you may want to provide a stage for that time later on. We can reify with t/on and t/at. reify [ree-uh-fahy, rey-] [2] verb (used with object), re·i·fied, re·i·fy·ing. to convert into or regard as a touchable thing: to reify a concept. You can think of a time (or a date) as stuff a partially specified date-time. Example 15. Reifying a date-time from dates and times If we have a stage of 1918-11-11, we can construct a date-time by giving the time of 11am with at: (-> (t/date "1918-11-11") (t/at "11:00")) Alternatively, if we have the time we can add the date: (-> (t/time "11:00") (t/on "1918-11-11")) We can moreover use reification to provide the location, with in. This allows us to take a local date-time and produce either a zoned-date-time or an offset-date-time. Example 16. Reifying a zoned-date-time from dates and times To construct the zoned-date-time of the Armistice of Compiègne with time, on and in: (-> (t/time "11:00") (t/on "1918-11-11") (t/in "Europe/Paris")) Alternatively, we can use t/offset-by in place of t/in, to produce an offset-date-time. (-> (t/time "11:00") (t/on "1918-11-11") (t/offset-by 2)) 4.4. Conversion With instants, insts (java.util.Date, JavaScript’s Date), zoned-date-times and offset-date-times, it’s easy to get stuck with the wrong type. Therefore, tick provides functions to convert between them. To convert between any of these types, simply undeniability the eponymous function respective to the destination type with the source type as an argument. Example 17. Converting between types To convert between an instant and a zoned-date-time: (t/zoned-date-time (t/now)) To convert between a zoned-date-time and an instant: (t/instant (t/zoned-date-time)) To convert between an instant and an inst: (t/inst (t/now)) It’s moreover possible to convert from strings to their destination types, which will involve parsing the string in to its most towardly type prior to conversion. In Java, types are converted equal to the rules in Table 1. Table 1. Converting between Java 8 types Convert between to instant to offset-date-time to zoned-date-time to inst from instant identity OffsetDateTime/ofInstant ZonedDateTime/ofInstant Date/from from offset-date-time .toInstant identity .toZonedDateTime .toInstant, Date/from from zoned-date-time .toInstant .toOffsetDateTime identity .toInstant, Date/from from inst .toInstant .toInstant, OffsetDateTime/ofInstant .toInstant, ZonedDateTime/ofInstant identity from String parse OffsetDateTime/parse ZonedDateTime/parse parse, then Date/from 4.5. Extraction Culturally, we understand time via calendars and it is often desirable to pericope unrepealable fields from time values. The day-of-week function extracts the day (of the week) from a time value, such as date, as shown in Example 18. Example 18. Extracting fields from a stage (t/day-of-week (t/date "2018-07-09")) (t/month (t/date "2018-07-09")) (t/year (t/date "2018-07-09")) Days of the week, and months of the year, are misogynist as constants listed in Table 2. Table 2. Tick constants and their respective host types Tick Java JavaScript tick.alpha.api/MONDAY java.time.DayOfWeek.MONDAY DayOfWeek.MONDAY tick.alpha.api/TUESDAY java.time.DayOfWeek.TUESDAY DayOfWeek.TUESDAY tick.alpha.api/WEDNESDAY java.time.DayOfWeek.WEDNESDAY DayOfWeek.WEDNESDAY tick.alpha.api/THURSDAY java.time.DayOfWeek.THURSDAY DayOfWeek.THURSDAY tick.alpha.api/FRIDAY java.time.DayOfWeek.FRIDAY DayOfWeek.FRIDAY tick.alpha.api/SATURDAY java.time.DayOfWeek.SATURDAY DayOfWeek.SATURDAY tick.alpha.api/SUNDAY java.time.DayOfWeek.SUNDAY DayOfWeek.SUNDAY tick.alpha.api/JANUARY java.time.Month.JANUARY Month.JANUARY tick.alpha.api/FEBRUARY java.time.Month.FEBRUARY Month.FEBRUARY tick.alpha.api/MARCH java.time.Month.MARCH Month.MARCH tick.alpha.api/APRIL java.time.Month.APRIL Month.APRIL tick.alpha.api/MAY java.time.Month.MAY Month.MAY tick.alpha.api/JUNE java.time.Month.JUNE Month.JUNE tick.alpha.api/JULY java.time.Month.JULY Month.JULY tick.alpha.api/AUGUST java.time.Month.AUGUST Month.AUGUST tick.alpha.api/SEPTEMBER java.time.Month.SEPTEMBER Month.SEPTEMBER tick.alpha.api/OCTOBER java.time.Month.OCTOBER Month.OCTOBER tick.alpha.api/NOVEMBER java.time.Month.NOVEMBER Month.NOVEMBER tick.alpha.api/DECEMBER java.time.Month.DECEMBER Month.DECEMBER We can use these constants to compare with = as shown in Example 19. Example 19. Comparing the day of the week from a stage Is the stage 2018-07-09 is a Monday? (= (t/day-of-week (t/date "2018-07-09")) t/MONDAY) But is the month May? (= (t/month (t/date "2018-07-09")) t/MAY) 4.6. Comparison TBD 4.7. Modification TBD 4.8. Truncation TBD 5. Durations & periods 5.1. ConstructionLawmakingDescription Return type (seconds 1)Elapsingof a second java.time.Duration (seconds 10)Elapsingof 10 seconds java.time.Duration (nanos 1200)Elapsingof 1200 nanoseconds java.time.Duration (days 100)Elapsingof 100 days java.time.Duration (period 100 :days) Period of 100 days java.time.Period (months 2) Period of 2 months java.time.Period Days, Months, Years… Instances of other java.time types are readily synthetic with tick. Example Description Return type (day "mon") Monday java.time.DayOfWeek (month "August") August java.time.Month (month 12) December java.time.Month (year-month "2012-12") December 2012 java.time.YearMonth (year 1999) The year 1999 java.time.Year 5.2. Derivation Add durations to durations 5.3. Comparison Note TBD 5.4. Misc Note TODO Don’t forget you can create zone-offsets from durations! Note TODO Don’t forget you can create instants from durations - this is often needed when you get Unix times (e.g. JWT OAuth2 tokens) The problem with numeric times is that there are cases where the units are in seconds and cases where milliseconds are used. If tick were to convert numbers to times, it would be a source of ravages and bugs if the units were not clear. For this reason, you cannot convert numbers to times. However, you can first create the elapsing from the number, specifying the units explicitly, and then convert the elapsing to an instant (or inst). (instant (new-duration 1531467976048 :millis)) (inst (new-duration 1531468976 :seconds)) 6. Clocks In tick, clocks are used for getting the current time, in a given time-zone. You should prefer using clocks to making uncontrived calls to (System/currentTimeMillis), considering this then allows you and others to plugin volitional clocks, perhaps for testing purposes. You create a clock that tracks the current time. (clock) With an argument, you can fix a clock to unchangingly report a stock-still time. (clock "1999-12-31T23:59:59") 6.1. ConstructionLawmakingDescription Return type (clock) Return a clock that will unchangingly return the current time java.time.Clock 6.2. Derivation Just like times and dates, you can time-shift clocks forward and wrong-side-up using the >> and << functions respectively. (<< (clock) (hours 2)) You can moreover create a clock from a wiring clock which reports time with granualarity given by a duration. (def minute-clk (tick (clock) (minutes 1)))LawmakingDescription Return type (<< (clock) (minutes 2)) Return a clock running 2 minutes slow java.time.Clock (>> (clock) (minutes 2)) Return a clock running 2 minutes fast java.time.Clock 6.3. Comparison Note TBD 6.4. Atomic clocks? In Clojure, an whit is a holder of a value at a particular time. Similarly, a tick whit is a clock holding the clock’s time, which is constantly changing. You create this whit with (atom). Naturally, you can get the instant of the atom’s clock by dereferencing, e.g. @(atom) user> (def clk (atom)) user> (println @clk) #object[java.time.Instant 0x2e014670 2018-02-28T07:52:52.302Z] (some time later) user> (println @clk) #object[java.time.Instant 0x6e5b1dca 2018-02-28T08:01:50.622Z] You can moreover create an whit with a clock. (atom (clock))LawmakingDescription Return type (atom) Return a clock that tracks the current time java.time.Clock 6.5. Substitution A clock can be used to callibrate tick to a particular time and time-zone, if system defaults are not desired. As I’m currently writing this in London, on my system I get the pursuit when I use '(zone)'. (zone) => #object[java.time.ZoneRegion 0x744a6545 "Europe/London"] However, if we wanted to test in New York, we can set the clock to exist in that time-zone: (t/with-clock (-> (t/clock) (t/in "America/New_York")) (t/zone)) => #object[java.time.ZoneRegion 0x5a9d412 "America/New_York"] 7. Intervals In tick, an interval is a span of time specified by two points in time, the first stuff surpassing the second. Intervals are maps containing both a tick/beginning and a tick/end entry. This flexible diamond allows any Clojure map to be treated as an interval. Intervals can be represented two local times as well as instants. 7.1. Construction Obviously, the Clojure’s literal syntax for maps can be used to create intervals. Here we use a literal map syntax to construct an interval representing the last 5 minutes of 2018 (in UTC). {:tick/beginning "2018-12-31T23:55:00Z" :tick/end "2019-01-01T00:00:00Z"} Alternatively, we can use the t/new-interval function which takes the two boundaries of the interval as its arguments. (t/new-interval (t/instant "2018-12-31T23:55:00Z") (t/instant "2019-01-01T00:00:00Z")) 7.2. Derivation Dates, months and years can moreover be considered to be themselves ranges, and can be converted to intervals with the t/bounds function. To return today as an interval: (t/bounds (t/today)) The arguments to t/new-interval do not have to be instants, they can be any time supported by tick. To return a 2-day interval spanning midnight this morning to midnight two days from today: (t/new-interval (t/today) (t/tomorrow)) 7.3. Comparison Two intervals can be compared versus each other with the t/relation function. Allen’s interval algebra tells us there are 13 possible relations between two intervals. Example 20. Interval relations Consider the time-span represented by the word 'yesterday' and compare it to the time-span represented by the word 'tomorrow'. Since yesterday is surpassing tomorrow, with a gap between them, we say that yesterday precedes tomorrow: (t/relation (t/yesterday) (t/tomorrow)) If the two intervals touch each other, in the specimen of 'today' and 'tomorrow', then we say the first interval (today) meets the second interval (tomorrow). (t/relation (t/today) (t/tomorrow)) To see other possible relations, use the slider in the diagram unelevated to move the top interval along: abc 7.4. Collections It is often useful to group intervals into collections and have functions operate on those collections. For example, you may want to gather together: all the time intervals when you were working last week system outages over a given period public holidays and weekends this year Note Discuss ordered sequences of disjoint intervals. 7.5. Demonstration 8. Calendars 8.1. Construction 8.2. Derivation 8.3. Comparison 9. Schedules 9.1. Construction 9.2. Derivation 9.3. Comparison 10. Formatting If it is de/serialization of java.time objects that is needed, then the jsr310-tagged-literals library is the right tool for that. Tick includes a small formatting api over that provided by jsr-310 In ClojureScript, require ns [tick.locale-en-us] to create custom formatters (require '[tick.alpha.api :as t]) (t/format :iso-zoned-date-time (tick/zoned-date-time)) (require '[tick.locale-en-us]) ; only need this require for custom format patterns ; and it's only needed for cljs, although the ns is cljc (t/format (tick.format/formatter "yyyy-MMM-dd") (tick/date)) 11. Cookbook 11.1. Introduction This cookbook aims to requite some examples of tick stuff used in variegated circumstances ranging from the very vital usage to increasingly ramified examples. 11.2. Times & dates Tick is flexible with the way in which times and dates are created; ergo, increasing efficiency. Times and dates can be hands stripped lanugo to smaller modules of time, likewise they can be built up into well-constructed instants. Create time A specific time can be produced in multiple ways with varying degrees of precision: (t/time "12:34") (t/time "12:34:56.789") (t/new-time 12 34) (t/new-time 12 34 56 789000000) Get the time To get the current time: (t/time) (t/new-time) Or the time from an instant: (t/time (t/instant "1999-12-31T23:59:59")) Get the current time in flipside time-zone: (t/time (t/in (t/now) "Australia/Darwin")) Get a specific unit of time: (t/hour (t/instant "1999-12-31T23:59:59")) (t/minute (t/instant "1999-12-31T23:59:59")) (t/second (t/instant "1999-12-31T23:59:59")) Create a stage Creating dates is washed-up in much the same way as creating time. (t/date "2000-01-01") (t/new-date 2000 01 01) Get the stage To get the current date: (t/date) (t/new-date) Or the stage from an instant: (t/date (t/instant "1999-12-31T23:59:59")) Get the stage in flipside time-zone: (t/date (t/in (t/instant "1999-12-31T23:59:59") "Australia/Darwin")) Get a specific part of the date: (t/year (t/instant "1999-12-31T23:59:59")) (t/month (t/instant "1999-12-31T23:59:59")) (t/day-of-month (t/instant "1999-12-31T23:59:59")) Build up times and dates A unique full-length of tick is that you can treat individual units of time as modular, making it easy to build up and unravel lanugo time into components.Unravelup an instant: (defn instant-breakdown "Takes an instant of time and breaks it lanugo into units." [t] {:day (t/day-of-week t) :month (t/month t) :dd (t/day-of-month t) :MM (t/int (t/month t)) :yyyy (t/int (t/year t)) :mm (t/minute t) :HH (t/hour t) :ss (t/second t)}) We can treat the individual units of time as towers blocks: Table 3. Tick Time Blocks TimeStageZone (t/time) (t/date) (t/zone) (t/hour) (t/minute) (t/second) (t/year) (t/month) (t/day-of-month) - - - (t/millisecond) (t/microsecond) (t/nanosecond) - - - - Make up a time If we want it to be half-past the current hour: (t/new-time (t/hour (t/instant)) 30) Or well-nigh lunch time: (t/new-time 13 (t/minute (t/instant))) Make up a date-time (t/at (t/date "2018-01-01") (t/time "13:00")) (t/on (t/time "13:00") (t/date "2018-01-01")) (-> (t/parse "1pm") (t/on "2018-10-20")) (-> (t/tomorrow) (t/at (t/midnight))) (-> (t/noon) (t/on (t/yesterday))) Make up a Zoned-Date-Time (-> (t/tomorrow) (t/at (t/midnight)) (t/in "Europe/Paris")) (-> (t/tomorrow) (t/at (t/midnight)) (t/in (t/zone))) Time andStagemanipulationRequitea stage a set time in the future: (t/+ (t/date "2000-01-01") (t/new-period 1 :months)) (t/+ (t/date "2000-01-01") (t/new-period 4 :weeks)) (t/+ (t/date "2000-01-01") (t/new-period 30 :days)) (t/+ (t/date "2000-01-01") (t/+ (t/new-period 5 :days) (t/new-period 1 :weeks) (t/new-period 10 :months))) Or past: (t/- (t/date "2000-01-01") (t/new-period 1 :years)) Move virtually in time: (t/+ (t/time "12:00") (t/new-duration 5 :minutes)) (t/- (t/time "12:00") (t/new-duration 5 :hours)) (t/>> (t/time "12:00") (t/+ (t/new-duration 5 :seconds) (t/new-duration 5 :millis) (t/new-duration 5 :micros) (t/new-duration 5 :nanos))) Increasing a time by a elapsing of day magnitude will leave the time vacated - 12:00 in 5 days is still 12:00 (ignoring daylight savings) (t/+ (t/time "12:00") (t/new-duration 5 :days)) Truncate time to a desired precision: (t/truncate (t/time "10:30:59.99") :minutes)Requitethe am pm time: (defn twelve-hour-time "Takes a time and gives the 12 hour display" [t] (let [minute (t/minute t) hour (t/hour t)] (cond (= (t/noon) t) "12:00 NOON" (>= hour 13) (format "%02d:%02d PM" (- hour 12) minute) (>= hour 12) (format "%02d:%02d PM" hour minute) (< hour 12) (format "%02d:%02d AM" hour minute)))) Note "12 noon is by definition neither rates meridiem (before noon) nor post meridiem (after noon), then 12 a.m. refers to midnight at the start of the specified day (00:00) and 12 p.m. to midnight at the end of that day (24:00)" - NPL 11.3. Instants and Inst tick’s default institute is java.time.Instant but caters for projects that use java.util.Date by the conversions above. It is recommended when using tick to alimony as an instant for as long as possible. Creation To get the current instant: (t/instant) (t/now) Create a specific instant: (t/instant "2000-01-01T00:00:00.001") Conversions between Inst and Instant Convert inst to and from instant: (t/instant (t/inst)) (t/inst (t/instant)) 11.4. Time Zones & OffsetPericopea zone from a java.time.ZonedDateTime: (t/zone (t/zoned-date-time "2000-01-01T00:00:00Z[Europe/Paris]")) (t/zone) Create a java.time.ZonedDateTime in a particular time zone: (t/in (t/instant "2000-01-01T00:00") "Australia/Darwin")Requitethe OffsetDateTime instead of ZonedDateTime: (t/offset-date-time (t/zoned-date-time "2000-01-01T00:00:00Z[Australia/Darwin]")) Specify the offset for a LocalDateTime: (t/offset-by (t/date-time "2018-01-01T00:00") 9) 11.5. Intervals An interval in time is a elapsing that has a specified whence and end. Create an interval There are multiple ways an interval can be created in tick: Specify the whence 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 whilom 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 elapsing of an interval can be modified using extend.Profferan instant to a interval (t/extend (t/instant "2000-01-01T00:00") (t/new-period 3 :weeks))Profferan 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 whence of an interval can be modified whilst preserving the duration. Shift the interval when 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)) 11.6. Arithmetic The tick library lends itself to doing additions, subtractions and divisions of time chunks and durations.Unelevatedare some examples of how time can be treated as a quantity which can be operated on. Simple maths Operating on an instant it will return flipside instant in time. Addition: (t/+ (t/now) (t/new-duration 15 :minutes)) Subtraction: (t/- (t/now) (t/new-duration 10 :days)) An interval has a whence and an end, operating on it will return a modified interval. Addition: (t/extend {:tick/beginning (t/instant "2018-01-01T00:00") :tick/end (t/instant "2018-01-10T00:00")} (t/new-period 10 :weeks)) Subtraction: (t/extend {:tick/beginning (t/instant "2018-01-01T00:00") :tick/end (t/instant "2018-01-10T00:00")} (t/new-duration -1 :days)) This can be washed-up with scale too: (= (t/extend (t/today) (t/new-period 10 :weeks)) (t/scale (t/today) (t/new-period 10 :weeks))) An interval can be divided into smaller intervals: Divide the day by 24, to get hour long intervals: (map #(apply t/new-interval %) (t/divide-by 24 {:tick/beginning (t/instant "2000-01-01T00:00") :tick/end (t/instant "2000-01-02T00:00")})) Or just divide the day by a elapsing of 1 hour to get the same result: (= (t/divide-by (t/new-duration 1 :hours) {:tick/beginning (t/instant "2000-01-01T00:00") :tick/end (t/instant "2000-01-02T00:00")}) (t/divide-by 24 {:tick/beginning (t/instant "2000-01-01T00:00") :tick/end (t/instant "2000-01-02T00:00")})) Durations can be treated like self-sustaining chunks of time. They can be extended, shrunk and divided. Addition: (t/+ (t/new-duration 1 :hours) (t/new-duration 10 :minutes)) Subtraction: (t/- (t/new-duration 1 :hours) (t/new-duration 10 :minutes)) Division: (t/divide (t/new-duration 1 :hours) (t/new-duration 1 :minutes)) 11.7.Warm-uptimers Creating a warm-up timer profoundly depends on the length of time stuff counted and the verism required. For a simple timer, usually only hours minutes and seconds are required: (defn countdown-HH-mm-ss [end-time] (let [duration (tick/duration {:tick/beginning (tick/instant) :tick/end end-time}) hours (tick/hours duration) minutes (tick/minutes (tick/- elapsing (tick/new-duration hours :hours))) seconds (tick/seconds (tick/- elapsing (tick/new-duration minutes :minutes) (tick/new-duration hours :hours)))] (if (tick/< (tick/instant) end-time) (format "%02d:%02d:%02d" hours minutes seconds) "Time's up!"))) For longer durations, counting to upper precision is unnecessary. If we are counting lanugo the weeks, knowing how many seconds remain is for the most part meaningless. (defn countdown-weeks [end-time] (let [duration (tick/duration {:tick/beginning (tick/instant) :tick/end end-time}) weeks (long (tick/divide elapsing (tick/new-duration 7 :days))) days (t/days (t/- elapsing (t/new-duration (* weeks 7) :days))) hours (tick/hours (tick/- elapsing (t/new-duration (+ days (* weeks 7)) :days)))] (if (tick/< (tick/instant) end-time) (format "%d weeks, %d days, %d hours" weeks days hours) "Time's up!"))) If you do not know the units of time that are going to be counted down, you may require a increasingly unstipulated warm-up function. (defn countdown-generic "Gives a map of the warm-up with units of time as keys." [end-time] (let [duration (tick/duration {:tick/beginning (tick/instant) :tick/end end-time}) weeks (long (tick/divide elapsing (tick/new-duration 7 :days))) days (t/days (t/- elapsing (t/new-duration (* weeks 7) :days))) hours (tick/hours (tick/- elapsing (t/new-duration (+ days (* weeks 7)) :days))) minutes (tick/minutes (tick/- elapsing (t/new-duration (+ days (* weeks 7)) :days) (t/new-duration hours :hours))) seconds (tick/seconds (tick/- elapsing (t/new-duration (+ days (* weeks 7)) :days) (t/new-duration hours :hours) (t/new-duration minutes :minutes))) millis (tick/millis (tick/- elapsing (t/new-duration (+ days (* weeks 7)) :days) (t/new-duration hours :hours) (t/new-duration minutes :minutes) (t/new-duration seconds :seconds)))] (if (tick/< (tick/instant) end-time) {:counting true :weeks weeks :days days :hours hours :minutes minutes :seconds seconds :milliseconds millis} {:counting false}))) It may be required that the time since an event is calculated. In this can be washed-up in a very similar way to counting down: (defn count-up "Gives the time since an event in the most towardly units of time" [event] (let [duration (tick/duration {:tick/beginning event :tick/end (tick/instant)}) years (long (tick/divide elapsing (tick/new-duration 365 :days))) months (long (tick/divide elapsing (tick/new-duration (/ 365 12) :days))) weeks (long (tick/divide elapsing (tick/new-duration 7 :days)))] (cond (> (t/days duration) 365) (format "%d years" years) (and (<= (t/days duration) 365) (> (t/days duration) (/ 365 12))) (format "%d months" months) (and (<= (t/days duration) (/ 365 12)) (> (t/days duration) 7)) (format "%d weeks" weeks) (and (<= (t/days duration) 7) (> (t/days duration) 1)) (format "%d days" (t/days duration)) (and (<= (t/days duration) 1) (> (t/hours duration) 1)) (format "%d hours %d" (t/hours duration)) (and (<= (t/hours duration) 1) (> (t/minutes duration) 1)) (format "%d minutes %d" (t/minutes duration)) (and (<= (t/minutes duration) 1) (> (t/seconds duration) 1)) (format "%d seconds" (t/seconds duration)) (tick/< (tick/instant) event) "Event hasn't happened yet"))) Caution These timers have lower verism at higher precisions - they do not worth for leap seconds or years. 11.8. Miscellaneous These examples don’t have a home yet. Check if an expiration has passed: (let [expiry (t/instant "2018-01-01T00:00")] (t/> (t/now) expiry)) Return a sequence of dates between two given dates a with a specified jump between each. For instance, to get a sequence of the first day of each month in a given year: (def intvl (t/bounds (t/year))) (t/range (t/beginning intvl) (t/end intvl) (t/new-period 1 :months)) Get the time difference between two instances: (t/between (t/now) (t/epoch)) Not sure on input format? parse will do the work for you. (t/parse "2 pm") (t/parse "14") (t/parse "14:00") (t/parse "2018-01-01") (t/parse "2018-01-01T00:00") (t/parse "2018-01-01T00:00:00") (t/parse "2018-01-01T00:00:00+01:00") (t/parse "2018-01-01T00:00:00+01:00[Europe/London]") (t/parse "2019") (t/parse "2000-01") 11.9. Tick Reference This section gives, in alphabetical order, examples of how to use each function in the tick api library. + - Add a elapsing to an instant: (t/+ (t/now) (t/new-duration 10 :minutes)) - - Subtract a elapsing to an instant: (t/- (t/now) (t/new-duration 10 :hours)) << - Go when 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")) <= -Surpassingor same time? (t/<= (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00")) >= -Withoutor same time? (t/>= (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00")) ago -Requitethe time a elapsing 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 stage (given stage at "time"): (-> (t/date "2000-01-01") (t/at "00:00")) whit - Create an holder for the current time: (def clk (t/atom)) (t/time @clk) whence -Requitethe whence of an interval: (t/beginning (t/today)) between -Requitea value for the elapsing between two instances: (t/between (t/instant "2000-01-01T00:00") (t/instant "2018-01-01T00:00")) premises -Requitethe whence and end of an interval: (t/bounds (t/yesterday)) clock - Create a system clock or stock-still clock: (t/clock) (t/clock (t/instant "2018-01-01T00:00")) coincident? - Are two intervals the same? (t/coincident? (t/today) (t/today)) complement -Requitethe 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 worldwide 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 hodgepodge with the original hodgepodge including a new date: (t/conj [(t/yesterday) (t/today)] (t/tomorrow)) stage - 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 elapsing into days (t/days (t/new-duration 24 :hours)) dec -Requitethe previous year: This does not work (t/dec (t/year)) difference - Return the first hodgepodge without the second hodgepodge elements. (t/difference [(t/yesterday) (t/today) (t/tomorrow)] [(t/today)]) divide - Divide a elapsing by flipside duration: (t/divide (t/new-duration 1 :days) (t/new-duration 1 :hours)) divide-by - Split an interval into plane sections of time: (t/divide-by 10 {:tick/beginning (t/instant "2018-01-01T00:00") :tick/end (t/instant "2018-01-10T00:00")}) elapsing -Requitethe elapsing of an interval: (t/duration {:tick/beginning (t/instant "2018-01-01T00:00") :tick/end (t/instant "2018-01-10T00:00")}) end -Requitethe end instance of an interval: (t/end {:tick/beginning (t/instant "2018-01-01T00:00") :tick/end (t/instant "2018-01-10T00:00")}) epoch -Requitethe epoch: (t/epoch) proffer -Profferan 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 hodgepodge 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 -Requitethe hour of the day: (t/hour (t/now)) hours -Requitea elapsing in hours: (t/hours (t/new-duration 2 :days)) in -Requitean instance in a time zone: (t/in (t/instant "2018-01-01T10:00") "Australia/Darwin") inc -Requitethe 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 -Requitethe year as an integer: (t/int (t/year)) intersection -Requitethe intersection of two sequences: (t/intersection [(t/year)] [(t/date "2017-01-01") (t/date "2018-01-01") (t/date "2019-01-01")]) intersects? - Does an interval intersect with another? (t/intersects? [(t/year)] (t/inc (t/year))) long - return an instant as a long: (t/long (t/instant)) max -Requitethe last chronological stage from multiple unordered dates: (t/max (t/today) (t/tomorrow) (t/yesterday) (t/new-date 2018 11 11)) micros -Requitea elapsing in microseconds: (t/micros (t/new-duration 5 :minutes)) microsecond -Requitethe microsecond of an instant: (t/microsecond (t/now)) midnight - Time at midnight: (t/midnight) midnight? - Is it midnight? (t/midnight? (t/date-time)) millis -Requitea elapsing in milliseconds: (t/millis (t/new-duration 5 :minutes)) millisecond -Requitethe millisecond of an instant. (t/millisecond (t/now)) min -Requitethe first chronological stage from an unordered list of dates: (t/min (t/today) (t/tomorrow) (t/yesterday) (t/new-date 2018 11 11)) minutes -Requitea elapsing in minutes: (t/minutes (t/new-duration 5 :hours)) minute -Requitethe 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) Note 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) Note 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 -Requitethe 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 -Requitenow as an instant: (t/now) offset-by -Requitea 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 -Requitea 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 -Requitethe most workable instance for the input string: (t/parse "1pm") pm -Requitean interval tent the afternoon of a given date: (t/pm (t/today)) range -Requitea 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)) Note see whilom for more. reset! - Reset an whit clock with one 5 mins slow. (def clk (t/atom)) (def clk2 (t/atom (t/<< (t/clock) (t/new-duration 5 :minutes)))) (t/reset! clk clk2) reset-vals! - Reset an whit clock with one 5 mins slow, and requite the value of surpassing and after. (def clk (t/atom)) (def 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 -Requitea elapsing in seconds: (t/seconds (t/new-duration 5 :minutes)) second -Requitethe second of time: (t/second (t/now)) time -Requitethe time of an instant: (t/time (t/now)) today -Requitetodays date: (t/today) tomorrow -Requitetomorrows 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 -Requitethe towardly units for a duration: (t/units (t/new-duration 1000000001 :nanos)) with - Return a stage with an unsimilar field: (t/with (t/today) :day-of-month 1) with-clock - Get the time from a clock: (def clk (t/>> (t/clock) (t/new-duration 5 :minutes))) (t/with-clock clk (t/time)) year -Requitethe year: (t/year) (t/year "2000-01-01") year-month -Requitethe year and month: (t/year-month) (t/year-month "2000-01-01") years -Requitea elapsing in years. (t/years (t/new-period 10 :years)) yesterday -Requiteyesterdays date: (t/yesterday) zone -Requitethe time zone: (t/zone) (t/zone (t/zoned-date-time "2000-01-01T00:00:00Z[Australia/Darwin]")) zone-offset -Requitethe 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]") References [ISO8601] ISO 8601: Data elements and interchange formats – Information interchange – Representation of dates and times 1. iso-8601,Dates are so often subject to regional conventions. Therefore in tick, we unchangingly parse and format dates equal to ISO 8601. 2. From reify at dictionary.com