-
Notifications
You must be signed in to change notification settings - Fork 0
API 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.
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. |
| 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. |
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..
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..
Interval.duration()
The length of this interval in milliseconds.
Returns Milliseconds spanned; zero when empty..
Interval.encloses(Interval other)
Whether this interval wholly contains another.
| Parameter | Meaning |
|---|---|
other |
The inner Interval. |
Returns true when other lies entirely within this..
Interval.equals(Interval other)
Whether two intervals have identical endpoints.
| Parameter | Meaning |
|---|---|
other |
The second Interval. |
Returns true when both endpoints match..
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..
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..
Interval.is_empty()
Whether this interval contains no instants at all.
Returns true when the end is not after the start..
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..
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"..
std_time v1 · API Index · Task Index · Scope and Limitations · Verification
Calendar data current to the horizons on Versioning and Data Currency. Shanghai, Bombay and Singapore answer exactly through 2026.
MPL-2.0 · Copyright (c) 2026 Jesse Sanford · published on TradingView as The_Peaceful_Lizard
Start here
The model
- Core Concepts
- Civil and Exact Arithmetic
- Value Semantics
- Error Model
- Time Zones
- Exchange Calendars
- Trading Days and Day Counts
- Expiries
- Sessions
- Formatting and Parsing
- Choosing the Right Tool
- Pitfalls
Recipes
Reference
- API Index · Task Index
- DateTime
- Session
- Zone
- Exchange
- Period · Interval
- Weekday · Enums
- Free functions
- Glossary
The fine print