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:
-
DeveloperError : timeStandard is not a known TimeStandard.
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:
Source:
Core/JulianDate.js, line 252
Methods
-
staticJulianDate.clone(date, result) → Cartesian3
-
Duplicates a JulianDate instance.
Name Type Description dateCartesian3 The JulianDate to duplicate. resultCartesian3 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)Source: Core/JulianDate.js, line 302 -
staticJulianDate.compare(a, b) → Number
-
Compares two JulianDate instances.
Name Type Description aJulianDate The first instance. bJulianDate 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.Source: Core/JulianDate.js, line 660 -
staticJulianDate.equals(left, right) → Boolean
-
Returns true if the first JulianDate equals the second JulianDate.
Name Type Description leftJulianDate The first JulianDate to compare for equality. rightJulianDate The second JulianDate to compare for equality. Returns:
trueif the JulianDates are equal; otherwise,false.Source: Core/JulianDate.js, line 676 -
staticJulianDate.equalsEpsilon(left, right, epsilon) → Boolean
-
Returns
trueif the provided dates 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 leftJulianDate The first JulianDate to be compared. rightJulianDate The second JulianDate to be compared. epsilonNumber The number of seconds that should separate the two JulianDates Returns:
trueif the two JulianDates are withinepsilonseconds of each other; otherwisefalse.See:
Source: Core/JulianDate.js, line 700 -
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 dateDate The JavaScript Date object representing the time to be converted to a JulianDate. timeStandardTimeStandard TimeStandard.UTCoptional Indicates the time standard in which this JulianDate is represented. Returns:
The newJulianDateinstance.Throws:
-
DeveloperError : date must be a valid JavaScript Date.
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:
Source: Core/JulianDate.js, line 339 -
-
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 iso8601StringString The ISO 8601 date string representing the time to be converted to a JulianDate. Returns:
The newJulianDateinstance.Throws:
-
DeveloperError : Valid ISO 8601 date string required.
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:
Source: Core/JulianDate.js, line 377 -
-
staticJulianDate.fromTotalDays(totalDays, timeStandard) → JulianDate
-
Creates a JulianDate instance from a single number representing the Julian day and fractional day.
Name Type Default Description totalDaysNumber The combined Julian Day Number and fractional day. timeStandardTimeStandard TimeStandard.UTCoptional Indicates the time standard in which the first parameter is defined. Returns:
The newJulianDateinstance.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:
Source: Core/JulianDate.js, line 638 -
addDays(duration) → JulianDate
-
Returns a new JulianDate representing a time
durationdays later (or earlier in the case of a negative amount).Name Type Description durationNumber An integer number of days to add or subtract. Returns:
A new JulianDate objectExample:
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 UTCSee:
Source: Core/JulianDate.js, line 1099 -
addHours(duration) → JulianDate
-
Returns a new JulianDate representing a time
durationhours later (or earlier in the case of a negative amount).Name Type Description durationNumber An integer number of hours to add or subtract. Returns:
A new JulianDate objectExample:
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 UTCSee:
Source: Core/JulianDate.js, line 1067 -
addMinutes(duration) → JulianDate
-
Returns a new JulianDate representing a time
durationminutes later (or earlier in the case of a negative amount).Name Type Description durationNumber An integer number of minutes to add or subtract. Returns:
A new JulianDate objectExample:
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 UTCSee:
Source: Core/JulianDate.js, line 1035 -
addSeconds(seconds, result) → JulianDate
-
Returns a new JulianDate representing a time
durationseconds later (or earlier in the case of a negative amount).Name Type Description secondsNumber The number of seconds to add or subtract. resultJulianDate 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 UTCSee:
Source: Core/JulianDate.js, line 1004 -
clone(result) → Cartesian3
-
Duplicates this JulianDate.
Name Type Description resultCartesian3 optional The object onto which to store the JulianDate. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Source: Core/JulianDate.js, line 717 -
compareTo(other) → Number
-
Compares this date to another date.
Name Type Description otherJulianDate 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.Source: Core/JulianDate.js, line 1209 -
equals(other) → Boolean
-
Returns
trueif this date is equivalent to the specified date.Name Type Description otherJulianDate The JulianDate to be compared. Returns:
trueif the two JulianDates are equal; otherwisefalse.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); // trueSee:
Source: Core/JulianDate.js, line 1229 -
equalsEpsilon(other, epsilon) → Boolean
-
Returns
trueif this date is withinepsilonseconds of the specified date. 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 otherJulianDate The JulianDate to be compared. epsilonNumber The number of seconds that should separate the two JulianDates Returns:
trueif the two JulianDates are withinepsilonseconds of each other; otherwisefalse.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); // trueSee:
Source: Core/JulianDate.js, line 1253 -
getDaysDifference(other) → Number
-
Computes the number of days that have elapsed from this JulianDate to the
otherJulianDate. A day is always exactly 86400.0 seconds.Name Type Description otherJulianDate 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 daysSee:
Source: Core/JulianDate.js, line 945 -
getJulianDayNumber() → Number
-
Returns the whole number component of the Julian date.
Returns:
A whole number representing the Julian day number. -
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. -
getMinutesDifference(other) → Number
-
Computes the number of minutes that have elapsed from this JulianDate to the
otherJulianDate.Name Type Description otherJulianDate 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 minutesSee:
Source: Core/JulianDate.js, line 923 -
getSecondsDifference(other) → Number
-
Computes the number of seconds that have elapsed from this JulianDate to the
otherJulianDate.Name Type Description otherJulianDate 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 secondsSee:
Source: Core/JulianDate.js, line 898 -
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. -
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 UTCExample:
var date = new Date('August 1, 2012 12:00:00 UTC'); var julianDate = Cesium.JulianDate.fromDate(date); var difference = julianDate.getTaiMinusUtc(); //35See:
Source: Core/JulianDate.js, line 968 -
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. -
greaterThan(other) → Boolean
-
Returns true if
otheroccurs before this JulianDate.Name Type Description otherJulianDate The JulianDate to be compared. Returns:
trueif this JulianDate is chronologically later thanother; 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); // trueSee:
Source: Core/JulianDate.js, line 1172 -
greaterThanOrEquals(other) → Boolean
-
Returns true if
otheroccurs at or before this JulianDate.Name Type Description otherJulianDate The JulianDate to be compared. Returns:
trueif this JulianDate is chronologically later 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')); end.greaterThanOrEquals(start); // trueSee:
Source: Core/JulianDate.js, line 1194 -
lessThan(other) → Boolean
-
Returns true if
otheroccurs after this JulianDate.Name Type Description otherJulianDate The JulianDate to be compared. Returns:
trueif this JulianDate is chronologically earlier thanother; 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); // trueSee:
Source: Core/JulianDate.js, line 1128 -
lessThanOrEquals(other) → Boolean
-
Returns true if
otheroccurs at or after this JulianDate.Name Type Description otherJulianDate The JulianDate to be compared. Returns:
trueif 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); // trueSee:
Source: Core/JulianDate.js, line 1150 -
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.Source: Core/JulianDate.js, line 844 -
toGregorianDate() → GregorianDate
-
Creates a GregorianDate representation of this date in UTC.
Returns:
A gregorian date.Source: Core/JulianDate.js, line 784 -
toIso8601(precision) → String
-
Creates an ISO8601 string represenation of this JulianDate in UTC.
Name Type Description precisionNumber 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.Source: Core/JulianDate.js, line 860
