### Get Interval Beginning with `beginning` Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc The `beginning` function returns the start of a given interval. `t/today` is used here as an example interval. ```clojure (t/beginning (t/today)) ``` -------------------------------- ### Example of DTSTART with Timezone Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Provides an example of a DTSTART component with a specified timezone (America/New_York) and a specific start time. This information is used to derive recurrence instances when not fully specified in the rule. ```icalendar DTSTART;TZID=America/New_York:19970105T083000 ``` -------------------------------- ### Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt An example of a DTSTART property with a specific date and time. ```icalendar DTSTART:19960415T133000Z ``` -------------------------------- ### VTODO Component: To-do Item Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Represents a to-do item with properties like start date, due date, summary, priority, and status. This example includes a priority and status. ```icalendar BEGIN:VTODO UID:19970901T130000Z-123404@host.com DTSTAMP:19970901T1300Z DTSTART:19970415T133000Z DUE:19970416T045959Z SUMMARY:1996 Income Tax Preparation CLASS:CONFIDENTIAL CATEGORIES:FAMILY,FINANCE PRIORITY:1 STATUS:NEEDS-ACTION END:VTODO ``` -------------------------------- ### IANA Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Illustrates examples of properties that can be registered with IANA. ```ical DRESSCODE:CASUAL ``` ```ical NON-SMOKING;VALUE=BOOLEAN:TRUE ``` -------------------------------- ### iCalendar DTSTART Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of the DTSTART property, specifying the start date and time of a calendar component. This property is required in VEVENT components. ```icalendar DTSTART:19980704 ``` -------------------------------- ### VTIMEZONE Component Example for New York City Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt An example demonstrating the complete time zone rules for America/New_York, including daylight and standard time observances with their respective start dates, recurrence rules, offsets, and names. ```icalendar BEGIN:VTIMEZONE TZID:America/New_York LAST-MODIFIED:20050809T050000Z BEGIN:DAYLIGHT DTSTART:19670430T020000 RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=-1SU;UNTIL=19730429T070000Z TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT BEGIN:STANDARD DTSTART:19671029T020000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20061029T060000Z TZOFFSETFROM:-0400 TZOFFSETTO:-0500 TZNAME:EST END:STANDARD BEGIN:DAYLIGHT DTSTART:19740106T020000 RDATE:19750223T020000 TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT BEGIN:DAYLIGHT DTSTART:19760425T020000 RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=-1SU;UNTIL=19860427T070000Z TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT BEGIN:DAYLIGHT DTSTART:19870405T020000 RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=20060402T070000Z TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT BEGIN:DAYLIGHT DTSTART:20070311T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT BEGIN:STANDARD ``` -------------------------------- ### PERIOD Value Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Examples demonstrating the two forms of PERIOD values: start/end date-time and start date-time/duration. These define a precise period of time. ```text 19970101T180000Z/19970102T070000Z ``` ```text 19970101T180000Z/PT5H30M ``` -------------------------------- ### LOCATION Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of the LOCATION property, showing a basic text venue and an example using the ALTREP parameter to specify a URI for alternate representation. ```icalendar LOCATION:Conference Room - F123, Bldg. 002 ``` ```icalendar LOCATION;ALTREP="http://xyzcorp.com/conf-rooms/f123.vcf": Conference Room - F123, Bldg. 002 ``` -------------------------------- ### URI Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt An example of a URI value type used to reference a network file. ```uri http://host1.com/my-report.txt ``` -------------------------------- ### Install Tick Library Source: https://context7.com/juxt/tick/llms.txt Add tick to your project's dependencies. For ClojureScript, additional js-joda dependencies are required. A babashka node REPL can be started with a one-liner. ```clojure ;; deps.edn {:deps {tick/tick {:mvn/version "1.0"}}} ;; ClojureScript (shadow-cljs or cljsjs) {:deps {tick/tick {:mvn/version "1.0"} henryw374/js-joda {:mvn/version "RELEASE"} henryw374/js-joda-locale-en-us {:mvn/version "RELEASE"} cljsjs/js-joda-timezone {:mvn/version "RELEASE"}}} ;; Babashka node REPL one-liner ;; clj -Sdeps '{:deps {tick/tick {:mvn/version "1.0"}}}' -m cljs.main -re node --repl ;; Namespace require (require '[tick.core :as t]) (require '[tick.alpha.interval :as t.i]) ``` -------------------------------- ### Install Tick Locally Source: https://github.com/juxt/tick/blob/master/README.adoc Install the Tick library to your local Maven repository (`~/.m2`). Use this to verify the build before releasing. ```makefile make install ``` -------------------------------- ### ATTACH Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples demonstrating the ATTACH property for associating documents with calendar components. Supports URI and BINARY values. ```ical ATTACH:CID:jsmith.part3.960817T083000.xyzMail@host1.com ``` ```ical ATTACH;FMTTYPE=application/postscript:ftp://xyzCorp.com/pub/ reports/r-960812.ps ``` -------------------------------- ### Non-Standard Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Provides an example of a vendor-specific extension property for an audio-clip subject. ```ical X-ABC-MMSUBJ;VALUE=URI;FMTTYPE=audio/basic:http://www.example. org/mysubj.au ``` -------------------------------- ### iCalendar DTSTART Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of the DTSTART property specifying a local date-time without a TZID parameter. ```icalendar DTSTART:19980118T073000Z ``` -------------------------------- ### iCalendar FREEBUSY Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of the FREEBUSY property defining free or busy time intervals. These examples demonstrate different FBTYPE parameters and multiple time periods. ```icalendar FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:19970308T160000Z/PT8H30M ``` ```icalendar FREEBUSY;FBTYPE=FREE:19970308T160000Z/PT3H,19970308T200000Z/PT1H ``` ```icalendar FREEBUSY;FBTYPE=FREE:19970308T160000Z/PT3H,19970308T200000Z/PT1H, 19970308T230000Z/19970309T000000Z ``` -------------------------------- ### VFREEBUSY Component Example (Reply) Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Example of a VFREEBUSY component used to reply with busy time information. Ensure all required properties are present for a valid response. ```icalendar BEGIN:VFREEBUSY UID:19970901T095957Z-76A912@example.com ORGANIZER:mailto:jane_doe@example.com ATTENDEE:mailto:john_public@example.com DTSTAMP:19970901T100000Z FREEBUSY:19971015T050000Z/PT8H30M, 19971015T160000Z/PT5H30M,19971015T223000Z/PT6H30M URL:http://example.com/pub/busy/jpublic-01.ifb COMMENT:This iCalendar file contains busy time information for the next three months. END:VFREEBUSY ``` -------------------------------- ### RDATE Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Examples demonstrating the RDATE property with different value types and parameters, including DATE-TIME, PERIOD, and DATE. ```icalendar RDATE:19970714T123000Z ``` ```icalendar RDATE;TZID=America/New_York:19970714T083000 ``` ```icalendar RDATE;VALUE=PERIOD:19960403T020000Z/19960403T040000Z, 19960404T010000Z/PT3H ``` ```icalendar RDATE;VALUE=DATE:19970101,19970120,19970217,19970421 19970526,19970704,19970901,19971014,19971128,19971129,19971225 ``` -------------------------------- ### iCalendar Extension Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of a vendor-specific extension property for an audio-clip subject. ```text X-ABC-MMSUBJ;X-ABC-MMSUBJTYPE=wave:http://load.noise.org/mysubj.wav ``` -------------------------------- ### Basic iCalendar Object Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt A simple example of an iCalendar object containing a VEVENT component. ```icalendar BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN BEGIN:VEVENT DTSTART:19970714T170000Z DTEND:19970715T035959Z SUMMARY:Bastille Day Party END:VEVENT END:VCALENDAR ``` -------------------------------- ### Install Clojurescript Dependencies Source: https://github.com/juxt/tick/blob/master/docs/cljs.adoc Run this command from your project directory to install npm dependencies required for webpack builds when using Tick. ```bash clj -m cljs.main --install-deps ``` -------------------------------- ### DUE Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Example of the DUE property for specifying a to-do completion date and time. ```icalendar DUE:19980430T000000Z ``` -------------------------------- ### DURATION Property Example (15 minutes) Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Specifies a positive duration of time. This example shows an interval of 15 minutes. ```icalendar DURATION:PT15M ``` -------------------------------- ### Getting the Time Source: https://github.com/juxt/tick/blob/master/docs/index.html Demonstrates how to get the current time of day and a specific time of day using the `t/time` function. ```APIDOC ## Getting the Time ### Description Get the current time of day or a specific time of day. ### Method `(t/time)` ### Parameters #### Arguments - `time-string` (string) - Optional - A string representing a specific time (e.g., "19:45"). ### Request Example ```clojure ;; Get current time (t/time) ;; Get a specific time (t/time "19:45") ``` ### Response #### Success Response - Returns a representation of the time of day. ``` -------------------------------- ### UTC Offset Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of UTC offsets representing standard time for New York and Geneva. ```text -0500 ``` ```text +0100 ``` -------------------------------- ### iCalendar VTODO Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of a VTODO (To-Do) component in iCalendar format. Includes details like due date, status, and an associated alarm. ```icalendar BEGIN:VCALENDAR VERSION:2.0 PRODID:-//ABC Corporation//NONSGML My Product//EN BEGIN:VTODO DTSTAMP:19980130T134500Z SEQUENCE:2 UID:uid4@host1.com ORGANIZER:MAILTO:unclesam@us.gov ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:jqpublic@host.com DUE:19980415T235959 STATUS:NEEDS-ACTION SUMMARY:Submit Income Taxes BEGIN:VALARM ACTION:AUDIO TRIGGER:19980403T120000 ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio- files/ssbanner.aud REPEAT:4 DURATION:PT1H END:VALARM END:VTODO END:VCALENDAR ``` -------------------------------- ### Simple iCalendar Object Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt A basic example of an iCalendar object, demonstrating the structure with essential properties like VERSION, PRODID, and a VEVENT component. ```ical BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN BEGIN:VEVENT UID:19970610T172345Z-AF23B2@example.com DTSTAMP:19970610T172345Z DTSTART:19970714T170000Z DTEND:19970715T040000Z SUMMARY:Bastille Day Party END:VEVENT END:VCALENDAR ``` -------------------------------- ### GEO Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt An example demonstrating the usage of the GEO property with latitude and longitude values. ```icalendar GEO:37.386013;-122.082932 ``` -------------------------------- ### TRANSP Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Examples of the TRANSP property to define event transparency for busy time searches. ```icalendar TRANSP:TRANSPARENT ``` ```icalendar TRANSP:OPAQUE ``` -------------------------------- ### iCalendar INTEGER Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of INTEGER properties representing signed integer values. ```icalendar 1234567890 ``` ```icalendar -1234567890 ``` ```icalendar +1234567890 ``` ```icalendar 432109876 ``` -------------------------------- ### BASE64 Encoded Binary Data Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt This example demonstrates the format of a BASE64 encoded binary value for an ATTACH property. It requires the ENCODING=BASE64 parameter. ```icalendar ATTACH;FMTTYPE=image/vnd.microsoft.icon;ENCODING=BASE64;VALUE =BINARY:AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgIAAAICAgADAwMAA////AAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAMwAAAAAAABNEMQAAAAAAAkQgAAAAAAJEREQgAA ACECQ0QgEgAAQxQzM0E0AABERCRCREQAADRDJEJEQwAAAhA0QwEQAAAAAERE AAAAAAAAREQAAAAAAAAkQgAAAAAAAAMgAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAA ``` -------------------------------- ### FREEBUSY Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Examples of the FREEBUSY property showing different busy/free time intervals. ```icalendar FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:19970308T160000Z/PT8H30M ``` ```icalendar FREEBUSY;FBTYPE=FREE:19970308T160000Z/PT3H,19970308T200000Z/PT1H ``` ```icalendar FREEBUSY;FBTYPE=FREE:19970308T160000Z/PT3H,19970308T200000Z/PT1H ,19970308T230000Z/19970309T000000Z ``` -------------------------------- ### VTODO Component Example (Date Due) Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Example of a VTODO component with a DATE value for the DUE property, indicating a deadline before which the task should be completed. ```icalendar BEGIN:VTODO UID:20070313T123432Z-456553@example.com DTSTAMP:20070313T123432Z DUE;VALUE=DATE:20070501 SUMMARY:Submit Quebec Income Tax Return for 2006 CLASS:CONFIDENTIAL CATEGORIES:FAMILY,FINANCE STATUS:NEEDS-ACTION END:VTODO ``` -------------------------------- ### Build Documentation Site Source: https://github.com/juxt/tick/blob/master/README.adoc Run this command to build the HTML documentation site. ```makefile make ``` -------------------------------- ### iCalendar DTSTART Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Demonstrates different formats for the DTSTART property: local time, UTC time, and local time with a time zone reference. ```text DTSTART:19970714T133000 ; Local time ``` ```text DTSTART:19970714T173000Z ; UTC time ``` ```text DTSTART;TZID=America/New_York:19970714T133000 ; Local time and time ; zone reference ``` -------------------------------- ### iCalendar PERIOD Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of PERIOD properties defining a precise period of time using start and end DATE-TIME or start DATE-TIME and DURATION. ```icalendar date-time "/" date-time ``` ```icalendar date-time "/" dur-value ``` -------------------------------- ### iCalendar CREATED Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Provides an example of the CREATED property, indicating the creation date and time of a calendar entry. ```icalendar CREATED:19960329T133000Z ``` -------------------------------- ### iCalendar RELATED Parameter Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Defines the relationship of an alarm trigger to a calendar component's start or end time. Use START to trigger relative to the component's start, or END to trigger relative to its end. Defaults to START if not specified. ```icalendar TRIGGER;RELATED=END:PT5M ``` -------------------------------- ### Build Production Documentation Site Source: https://github.com/juxt/tick/blob/master/README.adoc Command to build a production version of the documentation site. Note: This command is currently not working. ```makefile make release-docs-cljs ``` -------------------------------- ### DURATION Property Example (1 hour) Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Specifies a positive duration of time. This example shows an interval of one hour. ```icalendar DURATION:PT1H0M0S ``` -------------------------------- ### `beginning` - Give the beginning of an interval Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Returns the start point of a given interval. ```APIDOC ## `beginning` - Give the beginning of an interval ### Description Returns the start point of a given interval. ### Code Example ```clojure (t/beginning (t/today)) ``` ``` -------------------------------- ### Interval Creation and Bounds Source: https://context7.com/juxt/tick/llms.txt Demonstrates how to create new intervals and get the bounds for temporal units. ```APIDOC ## `tick.alpha.interval/new-interval` ### Description Creates a new interval map with `:tick/beginning` and `:tick/end` keys. ### Usage ```clojure (t.i/new-interval beginning end) ``` ## `tick.alpha.interval/bounds` ### Description Returns the interval representing the bounds of a given temporal unit (e.g., year, month). ### Usage ```clojure (t.i/bounds temporal-unit) ``` ### Example ```clojure (t.i/bounds (t/year 2024)) ;=> {:tick/beginning #time/date-time "2024-01-01T00:00" ; :tick/end #time/date-time "2025-01-01T00:00"} ``` ``` -------------------------------- ### Get Hour of Day with hour Source: https://github.com/juxt/tick/blob/master/docs/index.html Extracts the hour of the day from a time value. This function is available but no example is provided in the source. ```clojure (t/hour) ``` -------------------------------- ### Create and Relate Intervals with tick.alpha.interval Source: https://context7.com/juxt/tick/llms.txt Demonstrates creating intervals and checking basic Allen's Interval Algebra relations. Requires importing tick.core and tick.alpha.interval. ```clojure (require '[tick.core :as t]) (require '[tick.alpha.interval :as t.i]) ;; Create an interval (def jan (t.i/new-interval (t/date-time "2024-01-01T00:00") (t/date-time "2024-02-01T00:00"))) (def feb (t.i/new-interval (t/date-time "2024-02-01T00:00") (t/date-time "2024-03-01T00:00"))) (def mid-jan (t.i/new-interval (t/date-time "2024-01-10T00:00") (t/date-time "2024-01-20T00:00"))) ;; Bounds from a Year or YearMonth (t.i/bounds (t/year 2024)) ;=> {:tick/beginning #time/date-time "2024-01-01T00:00" ; :tick/end #time/date-time "2025-01-01T00:00"} ;; Allen's 13 basic relations (t.i/relation jan feb) ;=> :meets (t.i/precedes? jan feb) ;=> false (t.i/meets? jan feb) ;=> true (t.i/contains? jan mid-jan) ;=> true (t.i/during? mid-jan jan) ;=> true (t.i/overlaps? jan (t.i/new-interval (t/date-time "2024-01-15T00:00") (t/date-time "2024-02-15T00:00"))) ;=> true ``` ```clojure ;; Concur: find the overlapping interval between two intervals (t.i/concur jan (t.i/new-interval (t/date-time "2024-01-15T00:00") (t/date-time "2024-02-15T00:00"))) ;=> interval 2024-01-15 to 2024-02-01 ``` ```clojure ;; Extend an interval's end (t.i/extend jan (t/of-days 10)) ;=> interval from 2024-01-01 to 2024-02-11 ``` ```clojure ;; Scale an interval (t.i/scale jan 2) ;=> interval from 2024-01-01 spanning twice as long ``` ```clojure ;; Shift interval forward/backward (preserves duration) (t/>> jan (t/of-months 1)) ;=> same-length interval shifted to Feb-Mar (t/<< jan (t/of-days 7)) ;=> shifted one week earlier ``` -------------------------------- ### RRULE: FREQ=WEEKLY; INTERVAL=2; COUNT=4; BYDAY=TU,SU; WKST=MO Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt An example demonstrating how the WKST (Work Week Start day) parameter affects weekly recurrence. This rule specifies a bi-weekly recurrence of Tuesday and Sunday, with the week starting on Monday. ```icalendar DTSTART;TZID=US-Eastern:19970805T090000 RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO ``` -------------------------------- ### iCalendar DUE Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of the DUE property, defining the date and time a to-do is expected to be completed. The value must be equal to or after the DTSTART value, if specified. ```icalendar DUE:19980430T235959Z ``` -------------------------------- ### Convert to java.util.Date and Instant to Date with tick.core Source: https://context7.com/juxt/tick/llms.txt Demonstrates converting to `java.util.Date` and extracting the date part from an Instant, considering the zone. The round-trip example shows conversion between Instant and epoch milliseconds. ```clojure ;; To java.util.Date (inst) (t/inst (t/instant "2024-03-15T12:00:00Z")) (t/inst (t/zoned-date-time)) ;; Instant to year/month/day (uses *clock* zone; be explicit to avoid surprises) (-> (t/instant "2024-03-15T23:00:00Z") (t/in "America/New_York") (t/date)) ;=> #time/date "2024-03-15" ;; Round-trip: epoch millis <-> Instant (-> (t/instant) (cljc.java-time.instant/to-epoch-milli) (t/instant)) ``` -------------------------------- ### Calculate Future Instant Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `hence` to get an instant that is a specified duration from the current moment. This example calculates an instant 15 minutes from now. ```clojure (t/hence (t/new-duration 15 :minutes)) ``` -------------------------------- ### iCalendar DATE-TIME Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of DATE-TIME properties in iCalendar format, including local time, UTC, and time zone references. ```icalendar DTSTART;TZID=US-Eastern:19980119T020000 ``` ```icalendar DTSTART:19970714T133000 ;Local time ``` ```icalendar DTSTART:19970714T173000Z ;UTC time ``` ```icalendar DTSTART;TZID=US-Eastern:19970714T133000 ;Local time and time ; zone reference ``` ```icalendar COMPLETED:19970630T235960Z ``` -------------------------------- ### Get Interval Bounds with `bounds` Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc The `bounds` function returns a two-element vector containing the beginning and end of an interval. `t/yesterday` is used as an example. ```clojure (t.i/bounds (t/yesterday)) ``` -------------------------------- ### Verify Interval Equivalence Source: https://github.com/juxt/tick/blob/master/docs/cookbook/intervals.adoc This example demonstrates how to check if different methods of creating an interval result in the same temporal range. ```clojure (= (t.i/new-interval (t/date-time "2000-01-01T00:00") (t/date-time "2001-01-01T00:00")) (t.i/bounds (t/year 2000)) {:tick/beginning (t/date-time "2000-01-01T00:00") :tick/end (t/date-time "2001-01-01T00:00")}) ``` -------------------------------- ### ORGANIZER Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Demonstrates the basic usage of the ORGANIZER property with a common name. ```icalendar ORGANIZER;CN=John Smith:mailto:jsmith@example.com ``` -------------------------------- ### Reset an atom clock and get before/after values Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t/reset-vals!` to reset an atom clock and return the values before and after the reset. The example resets with a clock that is 5 minutes slow. ```clojure (let [clk (t/atom) clk2 (t/atom (t/<< (t/clock) (t/new-duration 5 :minutes)))] (t/reset-vals! clk clk2)) ``` -------------------------------- ### iCalendar VJOURNAL Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of a VJOURNAL (Journal Entry) component in iCalendar format. Demonstrates the use of DESCRIPTION for detailed notes and categorization. ```icalendar BEGIN:VCALENDAR VERSION:2.0 PRODID:-//ABC Corporation//NONSGML My Product//EN BEGIN:VJOURNAL DTSTAMP:19970324T120000Z UID:uid5@host1.com ORGANIZER:MAILTO:jsmith@host.com STATUS:DRAFT CLASS:PUBLIC CATEGORY:Project Report, XYZ, Weekly Meeting DESCRIPTION:Project xyz Review Meeting Minutes Agenda 1. Review of project version 1.0 requirements. 2. Definition of project processes. 3. Review of project schedule. Participants: John Smith, Jane Doe, Jim Dandy -It was decided that the requirements need to be signed off by product marketing. -Project processes were accepted. -Project schedule needs to account for scheduled holidays and employee vacation time. Check with HR for specific dates. -New schedule will be distributed by Friday. - Next weeks meeting is cancelled. No meeting until 3/23. END:VJOURNAL END:VCALENDAR ``` -------------------------------- ### RRULE with WKST affecting day generation Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Demonstrates how the WKST (Weekday Start) parameter in RRULE affects the generated days for weekly recurrences. The first example uses WKST=MO, and the second uses WKST=SU, showing different output dates. ```icalendar DTSTART;TZID=America/New_York:19970805T090000 RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO ``` ```icalendar DTSTART;TZID=America/New_York:19970805T090000 RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU ``` -------------------------------- ### RRULE: FREQ=WEEKLY; INTERVAL=2; COUNT=4; BYDAY=TU,SU; WKST=SU Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt This rule shows the impact of changing the WKST parameter to Sunday, while keeping other parameters the same as the previous example. It illustrates how the start day of the week can alter the generated dates for weekly recurrences. ```icalendar DTSTART;TZID=US-Eastern:19970805T090000 RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU ``` -------------------------------- ### Get Date with `date` Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc The `date` function can be called with no arguments to get the current date, or with an instant, a date string, or `t/tomorrow` to get a specific date. ```clojure (t/date) ``` ```clojure (t/tomorrow) ``` ```clojure (t/date (t/instant "2018-01-01T00:00:00.00Z")) ``` ```clojure (t/date "2018-01-01") ``` -------------------------------- ### X-TIMEOFDAY Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Demonstrates different formats for representing time of day using the non-standard X-TIMEOFDAY property. ```text X-TIMEOFDAY:083000 ``` ```text X-TIMEOFDAY:133000Z ``` ```text X-TIMEOFDAY;TZID=US-Eastern:083000 ``` -------------------------------- ### iCalendar DURATION Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of the DURATION property specifying time intervals. The first example shows 1 hour, and the second shows 15 minutes. ```icalendar DURATION:PT1H0M0S ``` ```icalendar DURATION:PT15M ``` -------------------------------- ### URI Value Type Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Shows an example of the URI value type, used for referencing external resources. Property values of this type must follow RFC 3986 syntax. ```text http://example.com/my-report.txt ``` -------------------------------- ### Setup Babashka REPL with Tick Source: https://github.com/juxt/tick/blob/master/README.adoc Set the `BABASHKA_CLASSPATH` environment variable to include Tick for use in a Babashka REPL. Requires Babashka v1.2.174+. ```bash export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {tick/tick {:mvn/version "0.6.0"}}}') bb ``` -------------------------------- ### Get the time at noon Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t/noon` to get the time at noon. ```clojure (t/noon) ``` -------------------------------- ### Create a specific instant Source: https://github.com/juxt/tick/blob/master/docs/cookbook/inst.adoc Create a specific `java.time.Instant` by providing an ISO 8601 formatted string to `t/instant`. Ensure the string is correctly formatted. ```clojure (t/instant "2000-01-01T00:00:00.001Z") ``` -------------------------------- ### Get tomorrow's date Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t/tomorrow` to get the date for tomorrow. ```clojure (t/tomorrow) ``` -------------------------------- ### TZURL Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Provides a URI to a network location for an up-to-date version of a VTIMEZONE component. Useful for handling changes in time zone definitions. ```text TZURL:http://timezones.r.us.net/tz/US-California-Los_Angeles ``` -------------------------------- ### Get today's date Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t/today` to get the current date. ```clojure (t/today) ``` -------------------------------- ### VFREEBUSY Component Example (Publish) Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Example of a VFREEBUSY component used to publish busy time information. Note the inclusion of DTSTART and DTEND for the overall period of the published busy times. ```icalendar BEGIN:VFREEBUSY UID:19970901T115957Z-76A912@example.com DTSTAMP:19970901T120000Z ORGANIZER:jsmith@example.com DTSTART:19980313T141711Z DTEND:19980410T141711Z FREEBUSY:19980314T233000Z/19980315T003000Z FREEBUSY:19980316T153000Z/19980316T163000Z FREEBUSY:19980318T030000Z/19980318T040000Z URL:http://www.example.com/calendar/busytime/jsmith.ifb END:VFREEBUSY ``` -------------------------------- ### Get the current instant Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t/now` to get the current time as an instant. ```clojure (t/now) ``` -------------------------------- ### iCalendar Boolean Value Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of a property with a BOOLEAN value type. ```ical GIBBERISH:TRUE ``` -------------------------------- ### Get Current Date-Time Source: https://github.com/juxt/tick/blob/master/docs/dates.adoc Call `t/date-time` with no arguments to get the current date and time. ```clojure (t/date-time) ``` -------------------------------- ### TZID Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Examples of the TZID property for specifying time zone identifiers. ```icalendar TZID:America/New_York ``` ```icalendar TZID:America/Los_Angeles ``` ```icalendar TZID:/example.org/America/New_York ``` -------------------------------- ### Develop Tick Library Source: https://github.com/juxt/tick/blob/master/README.adoc Execute this command to start testing the Tick library in both Clojure and Clojurescript environments. ```clojure clj -Atest-clj:test-cljs ``` -------------------------------- ### Convert to Instant with tick.core Source: https://context7.com/juxt/tick/llms.txt Shows various ways to convert different time representations (zoned date-time, offset date-time, date-time, epoch millis, string) into a tick Instant. Be mindful of the zone used for date-time conversions. ```clojure ;; To Instant (t/instant (t/zoned-date-time "2024-03-15T12:00:00Z[UTC]")) (t/instant (t/offset-date-time "2024-03-15T12:00:00Z")) (t/instant (t/date-time "2024-03-15T12:00:00")) ;=> uses *clock* zone (t/instant 1710504000000) ;=> from epoch millis (t/instant "2024-03-15T12:00:00Z") ;=> from string ``` -------------------------------- ### DTEND Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Example of the DTEND property with DATE-TIME and DATE value types. ```icalendar DTEND:19960401T150000Z ``` ```icalendar DTEND;VALUE=DATE:19980704 ``` -------------------------------- ### VTODO Component Example (DateTime Due and Completed) Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Example of a VTODO component with DATE-TIME values for DUE and COMPLETED properties, showing a task that was due at a specific time and was finished earlier. ```icalendar BEGIN:VTODO UID:20070514T103211Z-123404@example.com DTSTAMP:20070514T103211Z DTSTART:20070514T110000Z DUE:20070709T130000Z COMPLETED:20070707T100000Z SUMMARY:Submit Revised Internet-Draft PRIORITY:1 STATUS:NEEDS-ACTION END:VTODO ``` -------------------------------- ### iCalendar CONTACT Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of the CONTACT property with textual contact information. ```icalendar CONTACT:Jim Dolittle\, ABC Industries\, +1-919-555-1234 ``` -------------------------------- ### iCalendar FLOAT Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Examples of FLOAT properties representing real number values. ```icalendar 1000000.0000001 ``` ```icalendar 1.333 ``` ```icalendar -3.14 ``` -------------------------------- ### Contact Property Examples Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt Shows how to represent contact information using the CONTACT property, including textual and alternate representations. ```icalendar CONTACT:Jim Dolittle\, ABC Industries\, +1-919-555-1234 ``` ```icalendar CONTACT;ALTREP="ldap://example.com:6666/o=ABC%20Industries,c=US???(cn=Jim%20Dolittle)":Jim Dolittle\, ABC Industries\, +1-919-555-1234 ``` ```icalendar CONTACT;ALTREP="CID:part3.msg970930T083000SILVER@example.com":Jim Dolittle\, ABC Industries\, +1-919-555-1234 ``` ```icalendar CONTACT;ALTREP="http://example.com/pdi/jdoe.vcf":Jim Dolittle\, ABC Industries\, +1-919-555-1234 ``` -------------------------------- ### Getting the Date Source: https://github.com/juxt/tick/blob/master/docs/index.html Explains how to get the current date and a specific date using the `t/date` function. ```APIDOC ## Getting the Date ### Description Get the current calendar date or a specific date. ### Method `(t/date)` ### Parameters #### Arguments - `date-string` (string) - Optional - A string representing a specific date (e.g., "2018-06-21"). ### Request Example ```clojure ;; Get today's date (t/date) ;; Get a specific date (t/date "2018-06-21") ``` ### Response #### Success Response - Returns a representation of the calendar date. ``` -------------------------------- ### Get interval for the afternoon Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t.i/pm` to get an interval covering the afternoon of a given date. ```clojure (t.i/pm (t/today)) ``` -------------------------------- ### Convert between Inst and Instant Source: https://github.com/juxt/tick/blob/master/docs/cookbook/inst.adoc Use `t/instant` to convert an `Inst` to an `Instant`, and `t/inst` to convert an `Instant` to an `Inst`. These functions facilitate interoperability between the two types. ```clojure (t/instant (t/inst)) ``` ```clojure (t/inst (t/instant)) ``` -------------------------------- ### Get Next Year Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `inc` to get the next year relative to the current year. ```clojure (t/inc (t/year)) ``` -------------------------------- ### Instant Conversion to/from String Source: https://github.com/juxt/tick/blob/master/docs/cheatsheet.md Convert an instant to its ISO string representation or parse an ISO-formatted string into an instant. `str` can be used for the current instant. ```clojure (t/instant "2020-02-02T00:00:00Z") (t/... "2020...") (str (t/instant)) ``` -------------------------------- ### CLASS Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc2445.txt Example of the CLASS property, which defines the access classification for a calendar component. ```ical CLASS:PUBLIC ``` -------------------------------- ### Parse and Format Dates with Custom Patterns Source: https://github.com/juxt/tick/blob/master/docs/cheatsheet.md Use `t/parse-...` with a formatter to parse custom date strings, and `t/format` with a formatter to output dates in a specific pattern. ```clojure (t/parse-... "2021-..., (t/formatter "pattern")) (t/format (t/formatter "pattern") (t/date)) ``` -------------------------------- ### Create Zoned Date-Time for Tomorrow Midnight (System Zone) Source: https://github.com/juxt/tick/blob/master/docs/cookbook/time.adoc Creates a zoned date-time object for tomorrow midnight using the system's default timezone. ```clojure (-> (t/tomorrow) (t/at (t/midnight)) (t/in (t/zone))) ``` -------------------------------- ### Get OffsetDateTime with specified offset Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `t/offset-by` to get a `java.time.OffsetDateTime` for a specified instant with a given offset. ```clojure (t/offset-by (t/now) 1) ``` -------------------------------- ### Get Midnight Time Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Call `midnight` to get the time representing midnight (00:00:00) of the current day. ```clojure (t/midnight) ``` -------------------------------- ### instant Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Convert to `java.time.Instant`. ```APIDOC ## instant ### Description Convert to `java.time.Instant`. ### Method (t/instant [temporal]) ### Parameters #### Path Parameters - **temporal** (Temporal) - The temporal object to convert. ### Request Example ```clojure (t/instant (t/inst)) ``` ```clojure (t/instant (t/zoned-date-time "2018-01-01T00:00:00.000+09:30[Australia/Darwin]")) ``` ``` -------------------------------- ### Go Back in Time with `<<` Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `<<` to calculate a point in time that is a specified period before the current moment. Requires `t/now` and `t/new-period`. ```clojure (t/<< (t/now) (t/new-period 10 :weeks)) ``` -------------------------------- ### Convert to java.time.Instant Source: https://github.com/juxt/tick/blob/master/docs/cookbook/reference.adoc Use `instant` to convert a `java.util.Date` or a zoned date-time string into a `java.time.Instant` object. ```clojure (t/instant (t/inst)) ``` ```clojure (t/instant (t/zoned-date-time "2018-01-01T00:00:00.000+09:30[Australia/Darwin]")) ``` -------------------------------- ### Get Current Time in Clojure Source: https://github.com/juxt/tick/blob/master/README.adoc Requires importing the tick.core namespace. This snippet demonstrates how to get the current instant. ```clojure (require '[tick.core :as t]) ;; Get the current time (t/instant) ``` -------------------------------- ### Create YearMonth Instance Source: https://github.com/juxt/tick/blob/master/docs/durations.adoc Construct a YearMonth instance from a string representation of the year and month. ```clojure (year-month "2012-12") ``` -------------------------------- ### iCalendar DTEND Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt An example of the DTEND property, specifying the end date and time for a calendar component. ```icalendar DTEND:19960401T150000Z ``` -------------------------------- ### Deploy Tick to Clojars Source: https://github.com/juxt/tick/blob/master/README.adoc Deploy the Tick library to Clojars. Ensure your Clojars credentials are set up correctly. ```makefile make deploy ``` -------------------------------- ### iCalendar SUMMARY Property Example Source: https://github.com/juxt/tick/blob/master/docs/rfc5545.txt An example of the SUMMARY property, used to define a short subject for a calendar component. ```icalendar SUMMARY:Department Party ``` -------------------------------- ### Clocks and `with-clock` Source: https://context7.com/juxt/tick/llms.txt Manage the concept of 'now' using clocks, allowing for fixed times for testing or controlling time progression. ```APIDOC ## Clocks and `with-clock` Clocks control what "now" means in tick, enabling deterministic testing and timezone control. ```clojure (require '[tick.core :as t]) ;; Get current clock (t/clock) ;=> system default clock (t/current-zone) ;=> system default zone ;; Create a fixed clock at a specific time (great for testing) (def fixed-clock (t/clock (t/instant "2024-01-01T12:00:00Z"))) ;; with-clock macro: rebind *clock* for a scope (t/with-clock fixed-clock (t/instant)) ;=> #time/instant "2024-01-01T12:00:00Z" (t/with-clock fixed-clock (t/date)) ;=> #time/date "2024-01-01" ;; with-clock using a ZonedDateTime fixes both time and timezone (t/with-clock (t/zoned-date-time "2024-06-15T09:00:00-07:00[America/Los_Angeles]") [(t/date) (t/zone)]) ;=> [#time/date "2024-06-15", #time/zone "America/Los_Angeles"] ;; Shift a clock forward/backward (e.g., simulate time running fast) (t/<< (t/clock) (t/of-hours 2)) ;=> clock running 2 hours slow (t/>> (t/clock) (t/of-hours 2)) ;=> clock running 2 hours fast ;; Mutable atomic clock (def clk (t/atom)) @clk ;=> current Instant ;; advance the clock manually (t/swap! clk #(t/>> % (t/of-minutes 10))) ``` ```