JulianDate

new JulianDate(julianDayNumber, julianSecondsOfDay, timeStandard)

Constructs a JulianDate instance from a Julian day number, the number of seconds elapsed into that day, and the time standard which the parameters are in. Passing no parameters will construct a JulianDate that represents the current system time. An astronomical Julian date is the number of days since noon on January 1, -4712 (4713 BC). For increased precision, this class stores the whole number part of the date and the seconds part of the date in separate components. In order to be safe for arithmetic and represent leap seconds, the date is always stored in the International Atomic Time standard TimeStandard.TAI.
Name Type Default Description
julianDayNumber Number The Julian Day Number representing the number of whole days. Fractional days will also be handled correctly.
julianSecondsOfDay Number The number of seconds into the current Julian Day Number. Fractional seconds, negative seconds and seconds greater than a day will be handled correctly.
timeStandard TimeStandard TimeStandard.UTC optional The time standard in which the first two parameters are defined.
Throws:
Example:
// Example 1. Construct a JulianDate representing the current system time.
var julianDate = new Cesium.JulianDate();

// Example 2. Construct a JulianDate from a Julian day number and seconds of the day.
var julianDayNumber = 2448257;   // January 1, 1991
var secondsOfDay = 21600;        // 06:00:00
var julianDate = new Cesium.JulianDate(julianDayNumber, secondsOfDay, Cesium.TimeStandard.UTC);
See:

Methods

staticJulianDate.clone(date, result)Cartesian3

Duplicates a JulianDate instance.
Name Type Description
date Cartesian3 The JulianDate to duplicate.
result Cartesian3 optional The object onto which to store the JulianDate.
Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided. (Returns undefined if date is undefined)

staticJulianDate.compare(a, b)Number

Compares two JulianDate instances.
Name Type Description
a JulianDate The first instance.
b JulianDate The second instance.
Returns:
A negative value if a is less than b, a positive value if a is greater than b, or zero if a and b are equal.

staticJulianDate.equals(left, right)Boolean

Returns true if the first JulianDate equals the second JulianDate.
Name Type Description
left JulianDate The first JulianDate to compare for equality.
right JulianDate The second JulianDate to compare for equality.
Returns:
true if the JulianDates are equal; otherwise, false.

staticJulianDate.equalsEpsilon(left, right, epsilon)Boolean

Returns true if the provided dates 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.
Name Type Description
left JulianDate The first JulianDate to be compared.
right JulianDate The second JulianDate to be compared.
epsilon Number The number of seconds that should separate the two JulianDates
Returns:
true if the two JulianDates are within epsilon seconds of each other; otherwise false.
See:

staticJulianDate.fromDate(date, timeStandard)JulianDate

Creates a JulianDate instance from a JavaScript Date object. While the JavaScript Date object defaults to the system's local time zone, the JulianDate is computed using the UTC values.
Name Type Default Description
date Date The JavaScript Date object representing the time to be converted to a JulianDate.
timeStandard TimeStandard TimeStandard.UTC optional Indicates the time standard in which this JulianDate is represented.
Returns:
The new JulianDate instance.
Throws:
Example:
// Construct a JulianDate specifying the UTC time standard
var date = new Date('January 1, 2011 12:00:00 EST');
var julianDate = Cesium.JulianDate.fromDate(date, Cesium.TimeStandard.UTC);
See:

staticJulianDate.fromIso8601(iso8601String)JulianDate

Creates a JulianDate instance from an ISO 8601 date string. Unlike Date.parse, this method properly accounts for all valid formats defined by the ISO 8601 specification. It also properly handles leap seconds and sub-millisecond times.
Name Type Description
iso8601String String The ISO 8601 date string representing the time to be converted to a JulianDate.
Returns:
The new JulianDate instance.
Throws:
Example:
// Example 1. Construct a JulianDate in UTC at April 24th, 2012 6:08PM UTC
var julianDate = Cesium.JulianDate.fromIso8601('2012-04-24T18:08Z');
// Example 2. Construct a JulianDate in local time April 24th, 2012 12:00 AM
var localDay = Cesium.JulianDate.fromIso8601('2012-04-24');
// Example 3. Construct a JulianDate 5 hours behind UTC April 24th, 2012 5:00 pm UTC
var localDay = Cesium.JulianDate.fromIso8601('2012-04-24T12:00-05:00');
See:

staticJulianDate.fromTotalDays(totalDays, timeStandard)JulianDate

Creates a JulianDate instance from a single number representing the Julian day and fractional day.
Name Type Default Description
totalDays Number The combined Julian Day Number and fractional day.
timeStandard TimeStandard TimeStandard.UTC optional Indicates the time standard in which the first parameter is defined.
Returns:
The new JulianDate instance.
Example:
// Construct a date which corresponds to January 1, 1991 06:00:00 UTC.
var julianDate = Cesium.JulianDate.fromTotalDays(2448257.75, Cesium.TimeStandard.UTC);
See:

addDays(duration)JulianDate

Returns a new JulianDate representing a time duration days later (or earlier in the case of a negative amount).
Name Type Description
duration Number An integer number of days to add or subtract.
Returns:
A new JulianDate object
Example:
var date = new Date();
date.setUTCFullYear(2011, 6, 4);     // July 4, 2011 @ 12:00 UTC
date.setUTCHours(12, 0, 0, 0);
var start = Cesium.JulianDate.fromDate(date);
var end = start.addDays(5);         // July 9, 2011 @ 12:00 UTC
See:

addHours(duration)JulianDate

Returns a new JulianDate representing a time duration hours later (or earlier in the case of a negative amount).
Name Type Description
duration Number An integer number of hours to add or subtract.
Returns:
A new JulianDate object
Example:
var date = new Date();
date.setUTCFullYear(2011, 6, 4);     // July 4, 2011 @ 12:00 UTC
date.setUTCHours(12, 0, 0, 0);
var start = Cesium.JulianDate.fromDate(date);
var end = start.addHours(6);         // July 4, 2011 @ 18:00 UTC
See:

addMinutes(duration)JulianDate

Returns a new JulianDate representing a time duration minutes later (or earlier in the case of a negative amount).
Name Type Description
duration Number An integer number of minutes to add or subtract.
Returns:
A new JulianDate object
Example:
var date = new Date();
date.setUTCFullYear(2011, 6, 4);     // July 4, 2011 @ 12:00 UTC
date.setUTCHours(12, 0, 0, 0);
var start = Cesium.JulianDate.fromDate(date);
var end = start.addMinutes(65);      // July 4, 2011 @ 13:05 UTC
See:

addSeconds(seconds, result)JulianDate

Returns a new JulianDate representing a time duration seconds later (or earlier in the case of a negative amount).
Name Type Description
seconds Number The number of seconds to add or subtract.
result JulianDate optional The JulianDate to store the result into.
Returns:
The modified result parameter or a new JulianDate instance if it was not provided.
Example:
var date = new Date();
date.setUTCFullYear(2011, 6, 4);     // July 4, 2011 @ 12:00:00 UTC
date.setUTCHours(12, 0, 00, 0);
var start = Cesium.JulianDate.fromDate(date);
var end = start.addSeconds(95);      // July 4, 2011 @ 12:01:35 UTC
See:

clone(result)Cartesian3

Duplicates this JulianDate.
Name Type Description
result Cartesian3 optional The object onto which to store the JulianDate.
Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.

compareTo(other)Number

Compares this date to another date.
Name Type Description
other JulianDate The other JulianDate to compare to.
Returns:
A negative value if this instance is less than the other, a positive value if this instance is greater than the other, or zero if this instance and the other are equal.

equals(other)Boolean

Returns true if this date is equivalent to the specified date.
Name Type Description
other JulianDate The JulianDate to be compared.
Returns:
true if the two JulianDates are equal; otherwise false.
Example:
var original = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
var clone = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
original.equals(clone);      // true
See:

equalsEpsilon(other, epsilon)Boolean

Returns true if this date is within epsilon seconds of the specified date. 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.
Name Type Description
other JulianDate The JulianDate to be compared.
epsilon Number The number of seconds that should separate the two JulianDates
Returns:
true if the two JulianDates are within epsilon seconds of each other; otherwise false.
Example:
var original = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
var clone = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:01'));
original.equalsEpsilon(clone, 2);    // true
See:

getDaysDifference(other)Number

Computes the number of days that have elapsed from this JulianDate to the other JulianDate. A day is always exactly 86400.0 seconds.
Name Type Description
other JulianDate The other JulianDate, which is the end of the interval.
Returns:
The number of days that have elpased from this JulianDate to the other JulianDate.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 5, 2011 14:24:00'));
var difference = start.getDaysDifference(end);    // 1.1 days
See:

getJulianDayNumber()Number

Returns the whole number component of the Julian date.
Returns:
A whole number representing the Julian day number.
See:

getJulianTimeFraction()Number

Returns the floating point component of the Julian date representing the time of day.
Returns:
The floating point component of the Julian date representing the time of day.
See:

getMinutesDifference(other)Number

Computes the number of minutes that have elapsed from this JulianDate to the other JulianDate.
Name Type Description
other JulianDate The other JulianDate, which is the end of the interval.
Returns:
The number of seconds that have elpased from this JulianDate to the other JulianDate.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 5, 2011 12:01:00'));
var difference = start.getMinutesDifference(end);    // 1441.0 minutes
See:

getSecondsDifference(other)Number

Computes the number of seconds that have elapsed from this JulianDate to the other JulianDate.
Name Type Description
other JulianDate The other JulianDate, which is the end of the interval.
Returns:
The number of seconds that have elpased from this JulianDate to the other JulianDate.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 5, 2011 12:01:00'));
var difference = start.getSecondsDifference(end);    // 86460.0 seconds
See:

getSecondsOfDay()Number

Return the number of seconds elapsed into the current Julian day (starting at noon).
Returns:
The number of seconds elapsed into the current day.
See:

getTaiMinusUtc()Number

Returns the number of seconds this TAI date is ahead of UTC.
Returns:
The number of seconds this TAI date is ahead of UTC
Example:
var date = new Date('August 1, 2012 12:00:00 UTC');
var julianDate = Cesium.JulianDate.fromDate(date);
var difference = julianDate.getTaiMinusUtc(); //35
See:

getTotalDays()Number

Returns the total number of whole and fractional days represented by this astronomical Julian date.
Returns:
The Julian date as single floating point number.
See:

greaterThan(other)Boolean

Returns true if other occurs before this JulianDate.
Name Type Description
other JulianDate The JulianDate to be compared.
Returns:
true if this JulianDate is chronologically later than other; otherwise, false.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 6, 2011 12:01:00'));
end.greaterThan(start);      // true
See:

greaterThanOrEquals(other)Boolean

Returns true if other occurs at or before this JulianDate.
Name Type Description
other JulianDate The JulianDate to be compared.
Returns:
true if this JulianDate is chronologically later than or equal to other; otherwise, false.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 6, 2011 12:00:00'));
end.greaterThanOrEquals(start);      // true
See:

lessThan(other)Boolean

Returns true if other occurs after this JulianDate.
Name Type Description
other JulianDate The JulianDate to be compared.
Returns:
true if this JulianDate is chronologically earlier than other; otherwise, false.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 6, 2011 12:01:00'));
start.lessThan(end);     // true
See:

lessThanOrEquals(other)Boolean

Returns true if other occurs at or after this JulianDate.
Name Type Description
other JulianDate The JulianDate to be compared.
Returns:
true if this JulianDate is chronologically less than or equal toother; otherwise, false.
Example:
var start = Cesium.JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
var end = Cesium.JulianDate.fromDate(new Date('July 6, 2011 12:00:00'));
start.lessThanOrEquals(end);     // true
See:

toDate()Date

Creates a JavaScript Date representation of this date in UTC. Javascript dates are only accurate to the nearest millisecond.
Returns:
A new JavaScript Date equivalent to this JulianDate.

toGregorianDate()GregorianDate

Creates a GregorianDate representation of this date in UTC.
Returns:
A gregorian date.

toIso8601(precision)String

Creates an ISO8601 string represenation of this JulianDate in UTC.
Name Type Description
precision Number optional The number of fractional digits used to represent the seconds component. By default, the most precise representation is used.
Returns:
An ISO8601 string represenation of this JulianDate.