Tanguv0.35.0
Time & date72 exports
Raw Markdown

/chrono

High-precision clocks (Steady-Clock), civil dates/times (Date, Time, Date-Time), UTC Instants, IANA Zoned-Date-Time, and Duration/Span arithmetic powered by jiff.

(use /chrono)

Functions & symbols#

!=#

function
(!= left right) -> Bool

Returns `true` if two temporal values, durations, or spans are unequal.

ParameterTypeOptionalDescription
leftDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredLeft temporal value or duration
rightAnyrequiredComparable temporal value or duration
Returns:Any
(!= (Date 2026 3 15) (Date 2026 3 20))

+#

function
(+ temporal delta) -> Temporal

Adds a `Duration` or `Span` to a temporal point, or sums two durations/spans.

ParameterTypeOptionalDescription
temporalDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredBase temporal point or duration
deltaSpan | Duration | TemporalrequiredDelta duration/span or second instant for difference
Returns:Any
(+ (Date 2026 5 1) (chrono/days 7))

-#

function
(- temporal delta) -> Temporal

Subtracts a `Duration` or `Span` from a temporal point, or computes the elapsed duration/span between two points.

ParameterTypeOptionalDescription
temporalDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredBase temporal point or duration
deltaSpan | Duration | TemporalrequiredDelta duration/span or second instant for difference
Returns:Any
(- (Date 2026 5 10) (Date 2026 5 1))

<#

function
(< left right) -> Bool

Returns `true` if `left` occurs chronologically before (or is shorter than) `right`.

ParameterTypeOptionalDescription
leftDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredLeft temporal value or duration
rightAnyrequiredComparable temporal value or duration
Returns:Any
(< (Date 2026 3 15) (Date 2026 3 20))

<=#

function
(<= left right) -> Bool

Returns `true` if `left` occurs before or at the same instant as `right`.

ParameterTypeOptionalDescription
leftDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredLeft temporal value or duration
rightAnyrequiredComparable temporal value or duration
Returns:Any
(<= (Date 2026 3 15) (Date 2026 3 20))

==#

function
(== left right) -> Bool

Returns `true` if two temporal values, durations, or spans are equal.

ParameterTypeOptionalDescription
leftDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredLeft temporal value or duration
rightAnyrequiredComparable temporal value or duration
Returns:Any
(== (Date 2026 3 15) (Date 2026 3 20))

>#

function
(> left right) -> Bool

Returns `true` if `left` occurs chronologically after (or is longer than) `right`.

ParameterTypeOptionalDescription
leftDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredLeft temporal value or duration
rightAnyrequiredComparable temporal value or duration
Returns:Any
(> (Date 2026 3 15) (Date 2026 3 20))

>=#

function
(>= left right) -> Bool

Returns `true` if `left` occurs after or at the same instant as `right`.

ParameterTypeOptionalDescription
leftDate | Time | Date-Time | Instant | Steady-Instant | Zoned-Date-Time | Duration | SpanrequiredLeft temporal value or duration
rightAnyrequiredComparable temporal value or duration
Returns:Any
(>= (Date 2026 3 15) (Date 2026 3 20))

Date#

constructor
(Date year month day) -> Date

Constructs a civil calendar `Date` without time-of-day or timezone.

ParameterTypeOptionalDescription
year_or_strInt | String | MaprequiredCalendar year, ISO-8601 date string (`"2026-03-15"`), or fields map
monthIntoptionalMonth of year (1–12)
dayIntoptionalDay of month (1–31)
Returns:Any
(Date 2026 5 1)

Date-Time#

constructor
(Date-Time date time) -> Date-Time

Constructs a civil `Date-Time` combining date and time without timezone offset.

ParameterTypeOptionalDescription
date_or_yearDate | Int | StringrequiredCivil Date, year Int, or ISO-8601 datetime string
time_or_monthTime | IntoptionalCivil Time or month Int
Returns:Any
(Date-Time 2026 5 1 9 0 0)

Date-Time/local#

constructor
(Date-Time/local) -> Date-Time

Returns the current civil `Date-Time` in the system's local timezone.

Returns:Any
(Date-Time/local)

Date-Time/utc#

constructor
(Date-Time/utc) -> Date-Time

Returns the current civil `Date-Time` in UTC.

Returns:Any
(Date-Time/utc)

Date/local#

constructor
(Date/local) -> Date

Returns today's civil `Date` in the system's local timezone.

Returns:Any
(Date/local)

Date/utc#

constructor
(Date/utc) -> Date

Returns today's civil `Date` in UTC.

Returns:Any
(Date/utc)

Duration#

constructor
(Duration :seconds s :nanos ns ...) -> Duration

Constructs an exact physical `Duration` (fixed hours/minutes/seconds/subseconds).

ParameterTypeOptionalDescription
argsKeySymbol | Int | String | MaprequiredKey-value unit pairs (:hours, :minutes, :seconds, :millis, :micros, :nanos) or ISO-8601 duration string
Returns:Any
(Duration :minutes 5 :seconds 30)

Instant#

constructor
(Instant) -> Instant

Constructs an exact physical UTC `Instant` on the Unix epoch timeline (defaults to current time).

ParameterTypeOptionalDescription
valueInt | String | MapoptionalOptional Unix epoch seconds, RFC 3339 string, or {:millis ... :nanos ...} map
Returns:Any
(Instant)
(Instant "2026-05-01T12:00:00Z")

Span#

constructor
(Span :years y :months m :days d ...) -> Span

Constructs a calendar-aware `Span` supporting variable-length units like years, months, and weeks.

ParameterTypeOptionalDescription
argsKeySymbol | Int | String | MaprequiredKey-value unit pairs (:years, :months, :weeks, :days, :hours, :minutes, :seconds, ...) or ISO-8601 span string
Returns:Any
(Span :months 1 :days 5)

Steady-Clock/elapsed#

constructor
(Steady-Clock/elapsed since) -> Duration

Returns the exact elapsed `Duration` since `since`.

ParameterTypeOptionalDescription
sinceSteady-InstantrequiredEarlier Steady-Instant captured via Steady-Clock/now
Returns:Any
(let dt (Steady-Clock/elapsed start))

Steady-Clock/measure#

constructor
(Steady-Clock/measure func) -> Map

Executes `func` and returns `{:value result :duration elapsed-duration}`.

ParameterTypeOptionalDescription
funcFuncrequiredZero-argument function to benchmark
Returns:Any
(let res (Steady-Clock/measure (Func () (work))))

Steady-Clock/now#

constructor
(Steady-Clock/now) -> Steady-Instant

Captures the current reading of the host monotonic high-resolution clock.

Returns:Any
(let start (Steady-Clock/now))

Steady-Instant#

constructor
(Steady-Instant) -> Steady-Instant

Captures a monotonic clock reading immune to system wall-clock adjustments.

Returns:Any
(let t0 (Steady-Clock/now))

Time#

constructor
(Time hour minute [second [nanosecond]]) -> Time

Constructs a civil wall-clock `Time` without date or timezone.

ParameterTypeOptionalDescription
hour_or_strInt | String | MaprequiredHour (0–23), ISO-8601 time string, or fields map
minuteIntoptionalMinute (0–59)
secondIntoptionalOptional second (0–59)
nanosecondIntoptionalOptional nanosecond (0–999_999_999)
Returns:Any
(Time 14 30 0)

Time/local#

constructor
(Time/local) -> Time

Returns the current wall-clock `Time` in the system's local timezone.

Returns:Any
(Time/local)

Time/utc#

constructor
(Time/utc) -> Time

Returns the current wall-clock `Time` in UTC.

Returns:Any
(Time/utc)

Zoned-Date-Time#

constructor
(Zoned-Date-Time) -> Zoned-Date-Time

Constructs a timezone-aware `Zoned-Date-Time` referencing an IANA timezone database zone.

ParameterTypeOptionalDescription
targetString | Instant | Date-TimeoptionalRFC 9557 string or temporal value to project
timezoneStringoptionalIANA timezone name (e.g. "America/New_York", "UTC")
disambiguationKeySymboloptionalOptional DST disambiguation (:compatible, :earlier, :later, :reject)
Returns:Any
(Zoned-Date-Time (Instant) "Europe/Athens")

Zoned-Date-Time/in#

constructor
(Zoned-Date-Time/in timezone) -> Zoned-Date-Time

Returns the current wall time in the specified IANA `timezone`.

ParameterTypeOptionalDescription
timezoneStringrequiredIANA timezone identifier
Returns:Any
(Zoned-Date-Time/in "Asia/Tokyo")

Zoned-Date-Time/local#

constructor
(Zoned-Date-Time/local) -> Zoned-Date-Time

Returns the current `Zoned-Date-Time` in the host OS timezone.

Returns:Any
(Zoned-Date-Time/local)

Zoned-Date-Time/utc#

constructor
(Zoned-Date-Time/utc) -> Zoned-Date-Time

Returns the current `Zoned-Date-Time` in UTC.

Returns:Any
(Zoned-Date-Time/utc)

age#

function
(age birth-date [reference-date]) -> Span

Computes exact human calendar age between `birth_date` and `reference` as a balanced `Span`.

ParameterTypeOptionalDescription
birth_dateDate | Date-Time | Zoned-Date-TimerequiredStart date
referenceDate | Date-Time | Zoned-Date-TimeoptionalReference date (defaults to today UTC)
Returns:Any
(age (Date 1995 6 15) (Date 2026 6 15))

date-diff#

function
(date-diff start end [options]) -> Span

Computes the calendar/time difference between two temporal points as a `Span`.

ParameterTypeOptionalDescription
startDate | Time | Date-Time | Instant | Zoned-Date-TimerequiredStart temporal point
endDate | Time | Date-Time | Instant | Zoned-Date-TimerequiredEnd temporal point
optionsMapoptionalOptional {:largest :unit :smallest :unit}
Returns:Any
(date-diff (Date 2026 1 1) (Date 2026 3 1))

date-round#

function
(date-round unit temporal [options]) -> Temporal

Rounds a temporal value to `unit` with optional increment and rounding mode.

ParameterTypeOptionalDescription
unitKeySymbol | StringrequiredSmallest target unit (:day, :hour, :minute, :second, :millis, ...)
temporalTime | Date-Time | Instant | Zoned-Date-TimerequiredTemporal value to round
optionsMapoptionalRounding options {:mode :half-expand :increment 1}
Returns:Any
(date-round :minute (Instant))

date-trunc#

function
(date-trunc unit temporal) -> Temporal

Truncates smaller components of `temporal` down to the start of `unit`.

ParameterTypeOptionalDescription
unitKeySymbol | StringrequiredTruncation unit (:year, :month, :day, :hour, :minute, :second)
temporalDate | Time | Date-Time | Zoned-Date-Time | InstantrequiredTemporal value to truncate
Returns:Any
(date-trunc :day (Date-Time/utc))

day-of-week#

function
(day-of-week date) -> Int

Returns the 1-based Monday-indexed day of the week (1 = Monday .. 7 = Sunday).

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate or datetime to inspect
Returns:Any
(day-of-week (Date 2026 5 1))

day-of-week-iso#

function
(day-of-week-iso date) -> Int

Returns the ISO-8601 weekday number (1 = Monday through 7 = Sunday).

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate or datetime to inspect
Returns:Any
(day-of-week-iso (Date/utc))

day-of-week-symbol#

function
(day-of-week-symbol date) -> KeySymbol

Returns the weekday as a KeySymbol (`:mon`, `:tue`, `:wed`, `:thu`, `:fri`, `:sat`, `:sun`).

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate or datetime to inspect
Returns:Any
(day-of-week-symbol (Date 2026 5 1))

day-of-year#

function
(day-of-year date) -> Int

Returns the ordinal day within the year (1–365 or 1–366).

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate or datetime to inspect
Returns:Any
(day-of-year (Date 2026 12 31))

days#

function
(days n) -> Span

Constructs a calendar/clock `Span` representing `n` calendar days.

ParameterTypeOptionalDescription
nIntrequiredNumber of calendar days
Returns:Any
(+ (Date 2026 1 1) (days 2))

epoch-millis-of#

function
(epoch-millis-of instant) -> Int

Extracts Unix epoch milliseconds from a temporal value.

ParameterTypeOptionalDescription
temporalInstant | Zoned-Date-Time | Date-TimerequiredTemporal value
Returns:Any
(epoch-millis-of (Instant))

epoch-nanos-of#

function
(epoch-nanos-of instant) -> Int

Extracts Unix epoch nanoseconds from a temporal value.

ParameterTypeOptionalDescription
temporalInstant | Zoned-Date-Time | Date-TimerequiredTemporal value
Returns:Any
(epoch-nanos-of (Instant))

epoch-seconds-of#

function
(epoch-seconds-of instant) -> Int

Extracts whole Unix epoch seconds from a temporal value.

ParameterTypeOptionalDescription
temporalInstant | Zoned-Date-Time | Date-TimerequiredTemporal value
Returns:Any
(epoch-seconds-of (Instant))

format-date#

function
(format-date temporal pattern) -> String

Formats a temporal value using a `strftime`-compatible pattern string.

ParameterTypeOptionalDescription
temporalDate | Time | Date-Time | Zoned-Date-Time | InstantrequiredTemporal value to format
patternStringrequiredstrftime-compatible format string (e.g. "%Y-%m-%d %H:%M")
Returns:Any
(format-date (Date 2026 5 1) "%Y-%m-%d")

get-epoch-millis#

function
(get-epoch-millis) -> Int

Returns the current UTC Unix timestamp in milliseconds.

Returns:Any
(get-epoch-millis)

get-epoch-nanos#

function
(get-epoch-nanos) -> Int

Returns the current UTC Unix timestamp in nanoseconds.

Returns:Any
(get-epoch-nanos)

get-epoch-seconds#

function
(get-epoch-seconds) -> Int

Returns the current UTC Unix timestamp in whole seconds.

Returns:Any
(get-epoch-seconds)

hours#

function
(hours n) -> Span

Constructs a calendar/clock `Span` representing `n` hours.

ParameterTypeOptionalDescription
nIntrequiredNumber of hours
Returns:Any
(+ (Date 2026 1 1) (hours 2))

is-leap-year?#

function
(is-leap-year? date-or-year) -> Bool

Returns `true` if the year is a Gregorian leap year.

ParameterTypeOptionalDescription
targetDate | Date-Time | Zoned-Date-Time | IntrequiredTemporal value or 4-digit year integer
Returns:Any
(is-leap-year? 2024) ; -> true

is-weekday?#

function
(is-weekday? date) -> Bool

Returns `true` when `date` falls Monday through Friday.

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate to check
Returns:Any
(is-weekday? (Date/local))

is-weekend?#

function
(is-weekend? date) -> Bool

Returns `true` when `date` falls on Saturday or Sunday.

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate to check
Returns:Any
(is-weekend? (Date/local))

micros#

function
(micros n) -> Duration

Constructs an exact signed `Duration` representing `n` microseconds.

ParameterTypeOptionalDescription
nIntrequiredNumber of microseconds
Returns:Any
(+ (Instant) (micros 30))

millis#

function
(millis n) -> Duration

Constructs an exact signed `Duration` representing `n` milliseconds.

ParameterTypeOptionalDescription
nIntrequiredNumber of milliseconds
Returns:Any
(+ (Instant) (millis 30))

minutes#

function
(minutes n) -> Span

Constructs a calendar/clock `Span` representing `n` minutes.

ParameterTypeOptionalDescription
nIntrequiredNumber of minutes
Returns:Any
(+ (Date 2026 1 1) (minutes 2))

months#

function
(months n) -> Span

Constructs a calendar/clock `Span` representing `n` calendar months.

ParameterTypeOptionalDescription
nIntrequiredNumber of calendar months
Returns:Any
(+ (Date 2026 1 1) (months 2))

nanos#

function
(nanos n) -> Duration

Constructs an exact signed `Duration` representing `n` nanoseconds.

ParameterTypeOptionalDescription
nIntrequiredNumber of nanoseconds
Returns:Any
(+ (Instant) (nanos 30))

offset-of#

function
(offset-of zoned) -> Int

Returns the UTC offset in whole seconds for the `Zoned-Date-Time` at that instant.

ParameterTypeOptionalDescription
zonedZoned-Date-TimerequiredZoned datetime to inspect
Returns:Any
(offset-of (Zoned-Date-Time/utc)) ; -> 0

seconds#

function
(seconds n) -> Duration

Constructs an exact signed `Duration` representing `n` seconds.

ParameterTypeOptionalDescription
nIntrequiredNumber of seconds
Returns:Any
(+ (Instant) (seconds 30))

span-round#

function
(span-round span-or-unit [span] [options]) -> Span

Balances or rounds a `Span` across calendar/time units.

ParameterTypeOptionalDescription
unit_or_spanKeySymbol | SpanrequiredSmallest unit KeySymbol or Span
spanSpanoptionalSpan to balance/round when first arg is unit
optionsMapoptionalBalancing options {:largest :year :relative-to date}
Returns:Any
(span-round :second (chrono/Span :millis 65432))

span-total#

function
(span-total unit span [options]) -> Float

Computes the exact floating-point total length of a `Span` in `unit`.

ParameterTypeOptionalDescription
unitKeySymbolrequiredTarget unit (:days, :hours, :minutes, :seconds, ...)
spanSpan | DurationrequiredSpan or Duration to measure
optionsMapoptionalOptional {:relative-to ...} reference for calendar units
Returns:Any
(span-total :hours (chrono/Span :days 2 :hours 12)) ; -> 60.0

timezone-of#

function
(timezone-of zoned) -> String

Returns the IANA timezone identifier (e.g. `"Europe/Athens"`) or offset string.

ParameterTypeOptionalDescription
zonedZoned-Date-TimerequiredZoned datetime to inspect
Returns:Any
(timezone-of (Zoned-Date-Time/utc)) ; -> "UTC"

to-date#

function
(to-date target) -> Date

Extracts or parses a civil `Date`.

ParameterTypeOptionalDescription
targetDate-Time | Zoned-Date-Time | StringrequiredValue to project to civil Date
Returns:Any
(to-date (Date-Time/utc))

to-date-time#

function
(to-date-time target) -> Date-Time

Converts a zoned datetime or ISO string into a timezone-naive `Date-Time`.

ParameterTypeOptionalDescription
targetZoned-Date-Time | StringrequiredValue to convert to civil Date-Time
Returns:Any
(to-date-time (Zoned-Date-Time/utc))

to-duration#

function
(to-duration value) -> Duration

Converts a fixed-unit `Span`, ISO string, or map into an exact `Duration`.

ParameterTypeOptionalDescription
valueSpan | String | MaprequiredValue to convert to Duration
Returns:Any
(to-duration (chrono/minutes 10))

to-instant#

function
(to-instant target) -> Instant

Converts a zoned datetime, ISO string, or epoch integer into a physical `Instant`.

ParameterTypeOptionalDescription
targetZoned-Date-Time | String | IntrequiredValue to convert to Instant
Returns:Any
(to-instant (Zoned-Date-Time/local))

to-iso-string#

function
(to-iso-string temporal) -> String

Serializes a temporal value or span in canonical ISO-8601 format.

ParameterTypeOptionalDescription
temporalDate | Time | Date-Time | Zoned-Date-Time | Instant | Duration | SpanrequiredTemporal value
Returns:Any
(to-iso-string (Date 2026 5 1))

to-rfc-3339#

function
(to-rfc-3339 temporal) -> String

Formats an `Instant` or `Zoned-Date-Time` as an RFC 3339 UTC/offset timestamp.

ParameterTypeOptionalDescription
temporalInstant | Zoned-Date-Time | Date-TimerequiredTemporal instant
Returns:Any
(to-rfc-3339 (Instant))

to-span#

function
(to-span value) -> Span

Converts a `Duration`, ISO string, or map into a calendar `Span`.

ParameterTypeOptionalDescription
valueDuration | String | MaprequiredValue to convert to Span
Returns:Any
(to-span (chrono/seconds 90))

to-string#

function
(to-string temporal) -> String

Formats any `/chrono` temporal or duration value as a human-readable string.

ParameterTypeOptionalDescription
temporalAnyrequiredChrono temporal or duration value
Returns:Any
(to-string (chrono/minutes 5))

to-time#

function
(to-time target) -> Time

Extracts or parses a civil `Time`.

ParameterTypeOptionalDescription
targetDate-Time | Zoned-Date-Time | StringrequiredValue to project to civil Time
Returns:Any
(to-time (Date-Time/local))

to-zoned-date-time#

function
(to-zoned-date-time target timezone [disambiguation]) -> Zoned-Date-Time

Projects an `Instant` or `Date-Time` into the given IANA timezone.

ParameterTypeOptionalDescription
targetInstant | Date-Time | Zoned-Date-Time | StringrequiredTemporal value to attach timezone to
timezoneStringrequiredIANA timezone name
disambiguationKeySymboloptionalOptional DST disambiguation strategy
Returns:Any
(to-zoned-date-time (Instant) "UTC")

weekday-of#

function
(weekday-of date) -> Int

Alias of `day-of-week` returning ISO Monday=1 .. Sunday=7 weekday integer.

ParameterTypeOptionalDescription
dateDate | Date-Time | Zoned-Date-TimerequiredDate or datetime to inspect
Returns:Any
(weekday-of (Date/local))

weeks#

function
(weeks n) -> Span

Constructs a calendar/clock `Span` representing `n` 7-day weeks.

ParameterTypeOptionalDescription
nIntrequiredNumber of 7-day weeks
Returns:Any
(+ (Date 2026 1 1) (weeks 2))

with-timezone#

function
(with-timezone zoned timezone [disambiguation]) -> Zoned-Date-Time

Projects a temporal instant into a different IANA timezone.

ParameterTypeOptionalDescription
zonedZoned-Date-Time | Instant | Date-TimerequiredTemporal value
timezoneStringrequiredTarget IANA timezone identifier
disambiguationKeySymboloptionalOptional DST disambiguation option
Returns:Any
(with-timezone (Zoned-Date-Time/utc) "America/New_York")

years#

function
(years n) -> Span

Constructs a calendar/clock `Span` representing `n` calendar years.

ParameterTypeOptionalDescription
nIntrequiredNumber of calendar years
Returns:Any
(+ (Date 2026 1 1) (years 2))

Related modules