A labeled time interval event key.
new Interval({ value: "bucket", start, end })Constructor
new Interval(input: IntervalInput)
new Interval(["bucket", start, end])Creates a labeled interval key from a { value, start, end } object or tuple.
Properties
Static methods
fromCalendarstatic
fromCalendar(unit: CalendarUnit, reference: string, options?: TimeZoneOptions & { weekStartsOn?: WeekStartsOn } & { value?: IntervalValue }): Interval
Interval.fromCalendar("month", "2025-01", { timeZone: "America/New_York", value: "2025-01" })Creates a labeled calendar interval for the supplied reference.
fromDatestatic
fromDate(reference: string, options?: TimeZoneOptions & { value?: IntervalValue }): Interval
Interval.fromDate("2025-01-01", { timeZone: "UTC" })Creates a labeled local-day interval using the ISO date string as the default label.
Methods
asString
asString(): string
interval.asString()Returns the interval label as a string.
begin
begin(): number
interval.begin()Returns the inclusive start of the interval in milliseconds since epoch.
compare
compare(other: EventKey): number
interval.compare(otherInterval)Compares this key to another key for ordering.
contains
contains(other: TemporalLike): boolean
interval.contains(range)Returns true when this interval fully contains the supplied temporal value.
duration
duration(): number
interval.duration()Returns the temporal duration of the interval in milliseconds.
end
end(): number
interval.end()Returns the inclusive end of the interval in milliseconds since epoch.
equals
equals(other: EventKey): boolean
interval.equals(otherInterval)Returns true when the supplied key has the same label and temporal extent.
intersection
intersection(other: TemporalLike): TimeRange | undefined
interval.intersection(range)Returns the temporal intersection with the supplied value, if any.
isAfter
isAfter(other: TemporalLike): boolean
interval.isAfter(range)Returns true when this interval begins strictly after the supplied temporal value ends.
isBefore
isBefore(other: TemporalLike): boolean
interval.isBefore(range)Returns true when this interval ends strictly before the supplied temporal value begins.
overlaps
overlaps(other: TemporalLike): boolean
interval.overlaps(range)Returns true when this interval overlaps the supplied temporal value.
timeRange
timeRange(): TimeRange
interval.timeRange()Returns the interval extent as a TimeRange.
trim
trim(other: TemporalLike): Interval | undefined
interval.trim(range)Returns this interval clipped to the supplied temporal value, preserving its label when overlapping.
type
type(): 'interval'
interval.type() // "interval"Returns the key kind.
valueOf
valueOf(): IntervalValue
interval.valueOf()Returns the interval label.