Skip to content

API Interval

Jesse Sanford edited this page Aug 15, 2026 · 2 revisions

Interval

Concepts first: read Core Concepts before this page.

Signatures below are shown as the library declares them. From a script that imports it, every type and enum name takes your import alias: t.DateTime, t.Overflow.REJECT, t.Exchange.NYSE. A bare DateTime will not compile.

An Interval is a half-open span of instants, [FromMS, ToMS). Half-open so that consecutive intervals tile a timeline without overlapping at the join.

The type

Interval

type

A half-open span of instants, [FromMS, ToMS).

Field Declared as Meaning
FromMS int FromMS = 0 Inclusive start, Unix milliseconds.
ToMS int ToMS = 0 Exclusive end, Unix milliseconds.

Members

Summary
abuts Whether two intervals meet exactly end to start without overlapping: the condition under which they can be joined into one without a hole or a double count.
contains Whether an instant falls inside this interval.
duration The length of this interval in milliseconds.
encloses Whether this interval wholly contains another.
equals Whether two intervals have identical endpoints.
gap The empty span between two intervals that neither overlap nor touch.
intersection The overlapping part of two intervals.
is_empty Whether this interval contains no instants at all.
overlaps Whether two intervals share any instant.
to_iso This interval in ISO-8601 interval form, "start/end", with both endpoints in UTC.

Reference

abuts

Interval.abuts(Interval other)

Whether two intervals meet exactly end to start without overlapping: the condition under which they can be joined into one without a hole or a double count.

Parameter Meaning
other The second Interval.

Returns   true when one ends precisely where the other begins..

contains

Interval.contains(int unix_ms)

Whether an instant falls inside this interval. The interval is half-open, [FromMS, ToMS), so back-to-back intervals never both claim the same instant.

Parameter Meaning
unix_ms Unix timestamp in milliseconds.

Returns   true when FromMS <= unix_ms < ToMS..

duration

Interval.duration()

The length of this interval in milliseconds.

Returns   Milliseconds spanned; zero when empty..

encloses

Interval.encloses(Interval other)

Whether this interval wholly contains another.

Parameter Meaning
other The inner Interval.

Returns   true when other lies entirely within this..

equals

Interval.equals(Interval other)

Whether two intervals have identical endpoints.

Parameter Meaning
other The second Interval.

Returns   true when both endpoints match..

gap

Interval.gap(Interval other)

The empty span between two intervals that neither overlap nor touch.

Parameter Meaning
other The second Interval.

Returns   The gap Interval, or na when they overlap or abut..

intersection

Interval.intersection(Interval other)

The overlapping part of two intervals.

Parameter Meaning
other The second Interval.

Returns   The shared Interval, or na when they do not overlap..

is_empty

Interval.is_empty()

Whether this interval contains no instants at all.

Returns   true when the end is not after the start..

overlaps

Interval.overlaps(Interval other)

Whether two intervals share any instant. Half-open, so intervals that merely touch do not overlap.

Parameter Meaning
other The second Interval.

Returns   true when they intersect..

to_iso

Interval.to_iso()

This interval in ISO-8601 interval form, "start/end", with both endpoints in UTC.

Returns   A string such as "2026-08-21T13:30:00Z/2026-08-21T20:00:00Z"..


API Index  ·  Task Index  ·  Glossary

Clone this wiki locally