openspace.time
Functions overview
Name |
Documentation |
|---|---|
Modify a specified timestamp by a given delta time |
|
Convert the given time from either a J2000 seconds number to an ISO 8601 timestamp, or vice versa |
|
Returns the current application time as the number of seconds since the OpenSpace application started |
|
Returns the current time as the number of seconds since the J2000 epoch |
|
Returns the current wall time as an ISO 8601 date string (YYYY-MM-DDTHH-MN-SS) in the UTC timezone |
|
Returns the amount of simulated time that passes in one second of real time |
|
Returns the number of seconds between the provided start time and end time |
|
Set the amount of simulation time that happens in one second of real time, by smoothly interpolating to that value |
|
Interpolate the simulation speed to the first delta time step in the list that is larger than the current simulation speed, if any |
|
Same behaviour as |
|
Interpolate the simulation speed to the first delta time step in the list that is smaller than the current simulation speed, if any |
|
Set the current simulation time to the specified value, using interpolation |
|
Increment the current simulation time by the specified number of seconds, using interpolation |
|
Toggle the pause function, i |
|
Returns whether the simulation time is currently paused or is progressing |
|
This allows for a keypress (via keybinding) to have dual functionality |
|
Returns the number of seconds per day, where a day in this case is exactly 24 hours |
|
Returns the number of seconds in a Gregorian year, which is equal to 31556952 |
|
Set the amount of simulation time that happens in one second of real time |
|
Set the list of discrete delta time steps for the simulation speed that can be quickly jumped between |
|
Immediately set the simulation speed to the first delta time step in the list that is larger than the current choice of simulation speed, if any |
|
Set whether the simulation should be paused or not |
|
Immediately set the simulation speed to the first delta time step in the list that is smaller than the current choice of simulation speed, if any |
|
Set the current simulation time to the specified value |
|
Returns the current time as an date string |
|
Toggle the pause function, i |
|
Returns the current time as an ISO 8601 date string (YYYY-MM-DDTHH:MN:SS) |
Functions
advancedTime
Modify a specified timestamp by a given delta time. That is, advance the value either forwards or backwards in time.
The returned value will be of the same type as the first argument. That is, either a number of seconds past the J2000 epoch, or an ISO 8601 date string.
base
String | NumberThe timestamp to alter, either given as an ISO 8601 date string or a number of seconds past the J2000 epoch.
change
String | NumberThe amount of time to add to the specified timestamp. Can be given either in a number of seconds (including negative), or as a string of the form [-]XX(s,m,h,d,M,y] with (s)econds, (m)inutes, (h)ours, (d)ays, (M)onths, and (y)ears as units and an optional - sign to move backwards in time.
Return type: String | Number The updated timestamp
openspace.time.advancedTime(base, change)
convertTime
Convert the given time from either a J2000 seconds number to an ISO 8601 timestamp, or vice versa.
If the given time is a timestamp, the function returns a double precision value representing the ephemeris version of that time; that is, the number of TDB seconds past the J2000 epoch.
If the given time is a J2000 seconds value, the function returns a ISO 8601 timestamp.
time
String | NumberThe timestamp to convert, either given as an ISO 8601 date string or a number of seconds past the J2000 epoch.
Return type: String | Number The converted timestamp
openspace.time.convertTime(time)
currentApplicationTime
Returns the current application time as the number of seconds since the OpenSpace application started.
Return type: Number
openspace.time.currentApplicationTime()
currentTime
Returns the current time as the number of seconds since the J2000 epoch.
Return type: Number
openspace.time.currentTime()
currentWallTime
Returns the current wall time as an ISO 8601 date string (YYYY-MM-DDTHH-MN-SS) in the UTC timezone.
Return type: String
openspace.time.currentWallTime()
deltaTime
Returns the amount of simulated time that passes in one second of real time.
Return type: Number
openspace.time.deltaTime()
duration
Returns the number of seconds between the provided start time and end time.
If the end time is before the start time, the return value is negative. If the start time is equal to the end time, the return value is 0.
start
StringThe start time for the computation, given as an ISO 8601 date string
end
StringThe end time for the computation, given as an ISO 8601 date string
Return type: Number The time between the start time and end time
openspace.time.duration(start, end)
interpolateDeltaTime
Set the amount of simulation time that happens in one second of real time, by smoothly interpolating to that value.
deltaTime
NumberThe value to set the speed to, in seconds per real time second
interpolationDuration
Number?The number of seconds that the interpolation should be done over. If excluded, the time is decided based on the default value for delta time interpolation specified in the TimeManager.
Return type: void
openspace.time.interpolateDeltaTime(deltaTime, interpolationDuration)
interpolateNextDeltaTimeStep
Interpolate the simulation speed to the first delta time step in the list that is larger than the current simulation speed, if any.
interpolationDuration
Number?The number of seconds that the interpolation should be done over. If excluded, the time is decided based on the default value specified in the TimeManager.
Return type: void
openspace.time.interpolateNextDeltaTimeStep(interpolationDuration)
interpolatePause
Same behaviour as setPause, but with interpolation. That is, if it should be paused, the delta time will be interpolated to 0, and if unpausing, the delta time will be interpolated to whatever delta time value is set.
isPaused
BooleanTrue if the simulation should be paused, and false otherwise
interpolationDuration
Number?The number of seconds that the interpolation should be done over. If excluded, the time is decided based on the default value for pause/unpause specified in the TimeManager.
Return type: void
openspace.time.interpolatePause(isPaused, interpolationDuration)
interpolatePreviousDeltaTimeStep
Interpolate the simulation speed to the first delta time step in the list that is smaller than the current simulation speed, if any.
interpolationDuration
Number?The number of seconds that the interpolation should be done over. If excluded, the time is decided based on the default value specified in the TimeManager.
Return type: void
openspace.time.interpolatePreviousDeltaTimeStep(interpolationDuration)
interpolateTime
Set the current simulation time to the specified value, using interpolation. The time can be specified either a number of seconds past the J2000 epoch, or as a ISO 8601 string.
Note that providing time zone using the Z format is not supported. UTC is assumed.
time
String | NumberThe time to set. If the parameter is a number, the value is the number of seconds past the J2000 epoch. If it is a string, it has to be a valid ISO 8601-like date string of the format YYYY-MM-DDTHH:MN:SS.
interpolationDutation
Number?
Return type: void
openspace.time.interpolateTime(time, interpolationDutation)
interpolateTimeRelative
Increment the current simulation time by the specified number of seconds, using interpolation.
delta
NumberThe number of seconds to increase the current simulation time by
interpolationDuration
Number?The number of seconds that the interpolation should be done over. If excluded, the time is decided based on the default value for time interpolation specified in the TimeManager.
Return type: void
openspace.time.interpolateTimeRelative(delta, interpolationDuration)
interpolateTogglePause
Toggle the pause function, i.e. if the simulation is paused it will resume, and otherwise it will be paused. This is done by smoothly interpolating from the current delta time value to 0 (pause), or from 0 to the current delta time value (unpause).
interpolationDuration
Number?The number of seconds that the interpolation should be done over. If excluded, the time is decided based on the default value for pause/unpause specified in the TimeManager.
Return type: void
openspace.time.interpolateTogglePause(interpolationDuration)
isPaused
Returns whether the simulation time is currently paused or is progressing.
Return type: Boolean
openspace.time.isPaused()
pauseToggleViaKeyboard
This allows for a keypress (via keybinding) to have dual functionality. In normal operational mode it will behave just like time_interpolateTogglePause, but during playback of a session recording it will pause the playback without manipulating the delta time.
Return type: void
openspace.time.pauseToggleViaKeyboard()
secondsPerDay
Returns the number of seconds per day, where a day in this case is exactly 24 hours. The total number of seconds is equal to 86400.
Return type: Number
openspace.time.secondsPerDay()
secondsPerYear
Returns the number of seconds in a Gregorian year, which is equal to 31556952.
Return type: Number
openspace.time.secondsPerYear()
setDeltaTime
Set the amount of simulation time that happens in one second of real time.
deltaTime
NumberThe value to set the speed to, in seconds per real time second
Return type: void
openspace.time.setDeltaTime(deltaTime)
setDeltaTimeSteps
Set the list of discrete delta time steps for the simulation speed that can be quickly jumped between. The list will be sorted to be in increasing order. A negative verison of each specified time step will be added per default as well.
deltaTime
Number[]The list of delta times, given in seconds per real time second. Should only include positive values.
Return type: void
openspace.time.setDeltaTimeSteps(deltaTime)
setNextDeltaTimeStep
Immediately set the simulation speed to the first delta time step in the list that is larger than the current choice of simulation speed, if any.
Return type: void
openspace.time.setNextDeltaTimeStep()
setPause
Set whether the simulation should be paused or not. Note that to pause means temporarily setting the delta time to 0, and unpausing means restoring it to whatever delta time value is set.
isPaused
BooleanTrue if the simulation should be paused, and false otherwise
Return type: void
openspace.time.setPause(isPaused)
setPreviousDeltaTimeStep
Immediately set the simulation speed to the first delta time step in the list that is smaller than the current choice of simulation speed, if any.
Return type: void
openspace.time.setPreviousDeltaTimeStep()
setTime
Set the current simulation time to the specified value. The time can be specified either a number of seconds past the J2000 epoch, or as a ISO 8601 string.
Note that providing time zone using the Z format is not supported. UTC is assumed.
time
Number | StringThe time to set. If the parameter is a number, the value is the number of seconds past the J2000 epoch. If it is a string, it has to be a valid ISO 8601-like date string of the format YYYY-MM-DDTHH:MN:SS.
Return type: void
openspace.time.setTime(time)
SPICE
Returns the current time as an date string. The format of the returned string can be adjusted by providing the format picture. The default picture that is used will be (YYYY MON DDTHR:MN:SC.### ::RND). See https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html for documentation on how the format string can be formatted
format
String?- Default value:"YYYY MON DDTHR:MN:SC.### ::RND"
Return type: String
openspace.time.SPICE(format)
togglePause
Toggle the pause function, i.e. if the simulation is paused it will resume, and otherwise it will be paused. Note that to pause means temporarily setting the delta time to 0, and unpausing means restoring it to whatever delta time value is set.
Return type: void
openspace.time.togglePause()
UTC
Returns the current time as an ISO 8601 date string (YYYY-MM-DDTHH:MN:SS).
Return type: String
openspace.time.UTC()