new TimeInterval(options)
An interval defined by a start and a stop time; optionally including those times as part of the interval.
Arbitrary data can optionally be associated with each instance for used with
TimeIntervalCollection.
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
Object with the following properties:
|
Examples:
// Create an instance that spans August 1st, 1980 and is associated
// with a Cartesian position.
var timeInterval = new TimeInterval({
start : JulianDate.fromIso8601('1980-08-01T00:00:00Z'),
stop : JulianDate.fromIso8601('1980-08-02T00:00:00Z'),
isStartTimeIncluded : true,
iSStopTimeIncluded : false,
data : Cartesian.fromDegrees(39.921037, -75.170082)
});
// Create two instances from ISO 8601 intervals with associated numeric data
// then compute their intersection, summing the data they contain.
var left = TimeInterval.fromIso8601({
iso8601 : '2000/2010',
data : 2
});
var right = TimeInterval.fromIso8601({
iso8601 : '1995/2005',
data : 3
});
//The result of the below intersection will be an interval equivalent to
//var intersection = TimeInterval.fromIso8601({
// iso8601 : '2000/2005',
// data : 5
//});
var intersection = new TimeInterval();
TimeInterval.intersect(left, right, intersection, function(leftData, rightData) {
return leftData + rightData;
});
// Check if an interval contains a specific time.
var dateToCheck = JulianDate.fromIso8601('1982-09-08T11:30:00Z');
var containsDate = TimeInterval.contains(timeInterval, dateToCheck);
Source:
Core/TimeInterval.js, line 73
Members
-
staticconstantTimeInterval.EMPTY :TimeInterval
-
An immutable empty interval.Source: Core/TimeInterval.js, line 372
-
data :Object
-
Gets or sets the data associated with this interval.Source: Core/TimeInterval.js, line 91
-
readonlyisEmpty :Boolean
-
Gets whether or not this interval is empty.Source: Core/TimeInterval.js, line 115
-
isStartIncluded :Boolean
-
Gets or sets whether or not the start time is included in this interval.
-
Default Value:
trueSource: Core/TimeInterval.js, line 98 -
isStopIncluded :Boolean
-
Gets or sets whether or not the stop time is included in this interval.
-
Default Value:
trueSource: Core/TimeInterval.js, line 105 -
start :JulianDate
-
Gets or sets the start time of this interval.Source: Core/TimeInterval.js, line 79
-
stop :JulianDate
-
Gets or sets the stop time of this interval.Source: Core/TimeInterval.js, line 85
Methods
-
staticTimeInterval.clone(timeInterval, result) → TimeInterval
-
Duplicates the provided instance.
Name Type Description timeIntervalTimeInterval optional The instance to clone. resultTimeInterval optional An existing instance to use for the result. Returns:
The modified result parameter or a new instance if none was provided.Source: Core/TimeInterval.js, line 183 -
staticTimeInterval.contains(timeInterval, julianDate) → Boolean
-
Checks if the specified date is inside the provided interval.
Name Type Description timeIntervalTimeInterval The interval. julianDateJulianDate The date to check. Returns:
trueif the interval contains the specified date,falseotherwise.Source: Core/TimeInterval.js, line 303 -
staticTimeInterval.equals(left, right, dataComparer) → Boolean
-
Compares two instances and returns
trueif they are equal,falseotherwise.Name Type Description leftTimeInterval optional The first instance. rightTimeInterval optional The second instance. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif the dates are equal; otherwise,false.Source: Core/TimeInterval.js, line 206 -
staticTimeInterval.equalsEpsilon(left, right, epsilon, dataComparer) → Boolean
-
Compares two instances and returns
trueif they are withinepsilonseconds of each other. That is, in order for the dates to be considered equal (and for this function to returntrue), the absolute value of the difference between them, in seconds, must be less thanepsilon.Name Type Description leftTimeInterval optional The first instance. rightTimeInterval optional The second instance. epsilonNumber The maximum number of seconds that should separate the two instances. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif the two dates are withinepsilonseconds of each other; otherwisefalse.Source: Core/TimeInterval.js, line 229 -
staticTimeInterval.fromIso8601(options, result) → TimeInterval
-
Creates a new instance from an ISO 8601 interval.
Name Type Description optionsObject Object with the following properties: Name Type Default Description iso8601String An ISO 8601 interval. isStartIncludedBoolean trueoptional trueifoptions.startis included in the interval,falseotherwise.isStopIncludedBoolean trueoptional trueifoptions.stopis included in the interval,falseotherwise.dataObject optional Arbitrary data associated with this interval. resultTimeInterval optional An existing instance to use for the result. Returns:
The modified result parameter or a new instance if none was provided.Source: Core/TimeInterval.js, line 142 -
staticTimeInterval.intersect(left, right, result, mergeCallback) → TimeInterval
-
Computes the intersection of two intervals, optionally merging their data.
Name Type Description leftTimeInterval The first interval. rightTimeInterval optional The second interval. resultTimeInterval An existing instance to use for the result. mergeCallbackTimeInterval~MergeCallback optional A function which merges the data of the two intervals. If omitted, the data from the left interval will be used. Returns:
The modified result parameter.Source: Core/TimeInterval.js, line 255 -
clone(result) → TimeInterval
-
Duplicates this instance.
Name Type Description resultTimeInterval optional An existing instance to use for the result. Returns:
The modified result parameter or a new instance if none was provided.Source: Core/TimeInterval.js, line 336 -
equals(right, dataComparer) → Boolean
-
Compares this instance against the provided instance componentwise and returns
trueif they are equal,falseotherwise.Name Type Description rightTimeInterval optional The right hand side interval. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif they are equal,falseotherwise.Source: Core/TimeInterval.js, line 348 -
equalsEpsilon(right, epsilon, dataComparer) → Boolean
-
Compares this instance against the provided instance componentwise and returns
trueif they are within the provided epsilon,falseotherwise.Name Type Description rightTimeInterval optional The right hand side interval. epsilonNumber The epsilon to use for equality testing. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif they are within the provided epsilon,falseotherwise.Source: Core/TimeInterval.js, line 362
Type Definitions
-
DataComparer(leftData, rightData) → Boolean
-
Function interface for comparing interval data.
Name Type Description leftDataObject The first data instance. rightDataObject The second data instance. Returns:
trueif the provided instances are equal,falseotherwise.Source: Core/TimeInterval.js, line 388 -
MergeCallback(leftData, rightData) → Object
-
Function interface for merging interval data.
Name Type Description leftDataObject The first data instance. rightDataObject The second data instance. Returns:
The result of merging the two data instances.Source: Core/TimeInterval.js, line 379
