Class: TimeInterval

TimeInterval

new TimeInterval(optionsopt)

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.
Parameters:
Name Type Attributes Description
options Object <optional>
Object with the following properties:
Properties
Name Type Attributes Default Description
start JulianDate <optional>
new JulianDate() The start time of the interval.
stop JulianDate <optional>
new JulianDate() The stop time of the interval.
isStartIncluded Boolean <optional>
true true if options.start is included in the interval, false otherwise.
isStopIncluded Boolean <optional>
true true if options.stop is included in the interval, false otherwise.
data Object <optional>
Arbitrary data associated with this interval.
Source:
Examples
// Create an instance that spans August 1st, 1980 and is associated
// with a Cartesian position.
var timeInterval = new Cesium.TimeInterval({
    start : Cesium.JulianDate.fromIso8601('1980-08-01T00:00:00Z'),
    stop : Cesium.JulianDate.fromIso8601('1980-08-02T00:00:00Z'),
    isStartIncluded : true,
    isStopIncluded : false,
    data : Cesium.Cartesian3.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 = Cesium.TimeInterval.fromIso8601({
    iso8601 : '2000/2010',
    data : 2
});

var right = Cesium.TimeInterval.fromIso8601({
    iso8601 : '1995/2005',
    data : 3
});

//The result of the below intersection will be an interval equivalent to
//var intersection = Cesium.TimeInterval.fromIso8601({
//  iso8601 : '2000/2005',
//  data : 5
//});
var intersection = new Cesium.TimeInterval();
Cesium.TimeInterval.intersect(left, right, intersection, function(leftData, rightData) {
    return leftData + rightData;
});
// Check if an interval contains a specific time.
var dateToCheck = Cesium.JulianDate.fromIso8601('1982-09-08T11:30:00Z');
var containsDate = Cesium.TimeInterval.contains(timeInterval, dateToCheck);

Members

(static, constant) EMPTY :TimeInterval

An immutable empty interval.
Type:
Source:

data :Object

Gets or sets the data associated with this interval.
Type:
  • Object
Source:

(readonly) isEmpty :Boolean

Gets whether or not this interval is empty.
Type:
  • Boolean
Source:

isStartIncluded :Boolean

Gets or sets whether or not the start time is included in this interval.
Type:
  • Boolean
Default Value:
  • true
Source:

isStopIncluded :Boolean

Gets or sets whether or not the stop time is included in this interval.
Type:
  • Boolean
Default Value:
  • true
Source:

start :JulianDate

Gets or sets the start time of this interval.
Type:
Source:

stop :JulianDate

Gets or sets the stop time of this interval.
Type:
Source:

Methods

(static) clone(timeIntervalopt, resultopt) → {TimeInterval}

Duplicates the provided instance.
Parameters:
Name Type Attributes Description
timeInterval TimeInterval <optional>
The instance to clone.
result TimeInterval <optional>
An existing instance to use for the result.
Source:
Returns:
The modified result parameter or a new instance if none was provided.
Type
TimeInterval

(static) contains(timeInterval, julianDate) → {Boolean}

Checks if the specified date is inside the provided interval.
Parameters:
Name Type Description
timeInterval TimeInterval The interval.
julianDate JulianDate The date to check.
Source:
Returns:
true if the interval contains the specified date, false otherwise.
Type
Boolean

(static) equals(leftopt, rightopt, dataCompareropt) → {Boolean}

Compares two instances and returns true if they are equal, false otherwise.
Parameters:
Name Type Attributes Description
left TimeInterval <optional>
The first instance.
right TimeInterval <optional>
The second instance.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
Source:
Returns:
true if the dates are equal; otherwise, false.
Type
Boolean

(static) equalsEpsilon(leftopt, rightopt, epsilon, dataCompareropt) → {Boolean}

Compares two instances and returns true if they are within epsilon seconds of each other. That is, in order for the dates to be considered equal (and for this function to return true), the absolute value of the difference between them, in seconds, must be less than epsilon.
Parameters:
Name Type Attributes Description
left TimeInterval <optional>
The first instance.
right TimeInterval <optional>
The second instance.
epsilon Number The maximum number of seconds that should separate the two instances.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
Source:
Returns:
true if the two dates are within epsilon seconds of each other; otherwise false.
Type
Boolean

(static) fromIso8601(options, resultopt) → {TimeInterval}

Creates a new instance from an ISO 8601 interval.
Parameters:
Name Type Attributes Description
options Object Object with the following properties:
Properties
Name Type Attributes Default Description
iso8601 String An ISO 8601 interval.
isStartIncluded Boolean <optional>
true true if options.start is included in the interval, false otherwise.
isStopIncluded Boolean <optional>
true true if options.stop is included in the interval, false otherwise.
data Object <optional>
Arbitrary data associated with this interval.
result TimeInterval <optional>
An existing instance to use for the result.
Source:
Returns:
The modified result parameter or a new instance if none was provided.
Type
TimeInterval

(static) intersect(left, rightopt, result, mergeCallbackopt) → {TimeInterval}

Computes the intersection of two intervals, optionally merging their data.
Parameters:
Name Type Attributes Description
left TimeInterval The first interval.
right TimeInterval <optional>
The second interval.
result TimeInterval An existing instance to use for the result.
mergeCallback TimeInterval~MergeCallback <optional>
A function which merges the data of the two intervals. If omitted, the data from the left interval will be used.
Source:
Returns:
The modified result parameter.
Type
TimeInterval

(static) toIso8601(timeInterval, precisionopt) → {String}

Creates an ISO8601 representation of the provided interval.
Parameters:
Name Type Attributes Description
timeInterval TimeInterval The interval to be converted.
precision Number <optional>
The number of fractional digits used to represent the seconds component. By default, the most precise representation is used.
Source:
Returns:
The ISO8601 representation of the provided interval.
Type
String

clone(resultopt) → {TimeInterval}

Duplicates this instance.
Parameters:
Name Type Attributes Description
result TimeInterval <optional>
An existing instance to use for the result.
Source:
Returns:
The modified result parameter or a new instance if none was provided.
Type
TimeInterval

equals(rightopt, dataCompareropt) → {Boolean}

Compares this instance against the provided instance componentwise and returns true if they are equal, false otherwise.
Parameters:
Name Type Attributes Description
right TimeInterval <optional>
The right hand side interval.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
Source:
Returns:
true if they are equal, false otherwise.
Type
Boolean

equalsEpsilon(rightopt, epsilon, dataCompareropt) → {Boolean}

Compares this instance against the provided instance componentwise and returns true if they are within the provided epsilon, false otherwise.
Parameters:
Name Type Attributes Description
right TimeInterval <optional>
The right hand side interval.
epsilon Number The epsilon to use for equality testing.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
Source:
Returns:
true if they are within the provided epsilon, false otherwise.
Type
Boolean

toString() → {String}

Creates a string representing this TimeInterval in ISO8601 format.
Source:
Returns:
A string representing this TimeInterval in ISO8601 format.
Type
String

Type Definitions

DataComparer(leftData, rightData) → {Boolean}

Function interface for comparing interval data.
Parameters:
Name Type Description
leftData Object The first data instance.
rightData Object The second data instance.
Source:
Returns:
true if the provided instances are equal, false otherwise.
Type
Boolean

MergeCallback(leftData, rightData) → {Object}

Function interface for merging interval data.
Parameters:
Name Type Description
leftData Object The first data instance.
rightData Object The second data instance.
Source:
Returns:
The result of merging the two data instances.
Type
Object