Class: Interval

Interval

new Interval(isValid, startTime, endTime, interval)

An Interval defines a time duration which contains a start timestamp and an end timestamp. Create an Interval with one of these forms: Interval(isValid). Interval(startTime, endTime). Interval(interval).
Parameters:
Name Type Description
isValid boolean True to create a valid empty interval, false to create an invalid interval.
startTime number The start time as milliseconds since Jan 1, 1970 UTC. The start time must be less than the end time. To create an empty interval (start time equals end time), use the constructor Interval(true).
endTime number The end time as milliseconds since Jan 1, 1970 UTC.
interval Interval The other interval with values to copy.
Source:

Methods

covers(timePoint) → {boolean}

Check if the time point is in this interval.
Parameters:
Name Type Description
timePoint number The time point to check as milliseconds since Jan 1, 1970 UTC.
Source:
Throws:
Error if this Interval is invalid.
Returns:
True if timePoint is in this interval.
Type
boolean

getEndTime() → {number}

Get the end time.
Source:
Throws:
Error if this Interval is invalid.
Returns:
The end time as milliseconds since Jan 1, 1970 UTC.
Type
number

getStartTime() → {number}

Get the start time.
Source:
Throws:
Error if this Interval is invalid.
Returns:
The start time as milliseconds since Jan 1, 1970 UTC.
Type
number

intersectWith(interval) → {Interval}

Set this Interval to the intersection of this and the other interval. This and the other interval should be valid but either can be empty.
Parameters:
Name Type Description
interval Interval The other Interval to intersect with.
Source:
Throws:
Error if this Interval or the other interval is invalid.
Returns:
This Interval.
Type
Interval

isEmpty() → {boolean}

Check if this Interval is empty.
Source:
Throws:
Error if this Interval is invalid.
Returns:
True if this Interval is empty (start time equals end time), false if not.
Type
boolean

isValid() → {boolean}

Check if this Interval is valid.
Source:
Returns:
True if this interval is valid, false if invalid.
Type
boolean

set(other)

Set this interval to have the same values as the other interval.
Parameters:
Name Type Description
other Interval The other Interval with values to copy.
Source:

unionWith(interval) → {Interval}

Set this Interval to the union of this and the other interval. This and the other interval should be valid but either can be empty. This and the other interval should have an intersection. (Contiguous intervals are not allowed.)
Parameters:
Name Type Description
interval Interval The other Interval to union with.
Source:
Throws:
Error if this Interval or the other interval is invalid, or if the two intervals do not have an intersection.
Returns:
This Interval.
Type
Interval