openspace.time

Functions overview

Name

Documentation

advancedTime

Modify a specified timestamp by a given delta time

convertTime

Convert the given time from either a J2000 seconds number to an ISO 8601 timestamp, or vice versa

currentApplicationTime

Returns the current application time as the number of seconds since the OpenSpace application started

currentTime

Returns the current time as the number of seconds since the J2000 epoch

currentWallTime

Returns the current wall time as an ISO 8601 date string (YYYY-MM-DDTHH-MN-SS) in the UTC timezone

deltaTime

Returns the amount of simulated time that passes in one second of real time

duration

Returns the number of seconds between the provided start time and end time

interpolateDeltaTime

Set the amount of simulation time that happens in one second of real time, by smoothly interpolating to that value

interpolateNextDeltaTimeStep

Interpolate the simulation speed to the first delta time step in the list that is larger than the current simulation speed, if any

interpolatePause

Same behaviour as setPause, but with interpolation

interpolatePreviousDeltaTimeStep

Interpolate the simulation speed to the first delta time step in the list that is smaller than the current simulation speed, if any

interpolateTime

Set the current simulation time to the specified value, using interpolation

interpolateTimeRelative

Increment the current simulation time by the specified number of seconds, using interpolation

interpolateTogglePause

Toggle the pause function, i

isPaused

Returns whether the simulation time is currently paused or is progressing

pauseToggleViaKeyboard

This allows for a keypress (via keybinding) to have dual functionality

secondsPerDay

Returns the number of seconds per day, where a day in this case is exactly 24 hours

secondsPerYear

Returns the number of seconds in a Gregorian year, which is equal to 31556952

setDeltaTime

Set the amount of simulation time that happens in one second of real time

setDeltaTimeSteps

Set the list of discrete delta time steps for the simulation speed that can be quickly jumped between

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

setPause

Set whether the simulation should be paused or not

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

setTime

Set the current simulation time to the specified value

SPICE

Returns the current time as an date string

togglePause

Toggle the pause function, i

UTC

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.

Parameters
  • base String | Number

    • The timestamp to alter, either given as an ISO 8601 date string or a number of seconds past the J2000 epoch.

  • change String | Number

    • The 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

Signature
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.

Parameters
  • time String | Number

    • The 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

Signature
openspace.time.convertTime(time)

currentApplicationTime

Returns the current application time as the number of seconds since the OpenSpace application started.

Return type: Number

Signature
openspace.time.currentApplicationTime()

currentTime

Returns the current time as the number of seconds since the J2000 epoch.

Return type: Number

Signature
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

Signature
openspace.time.currentWallTime()

deltaTime

Returns the amount of simulated time that passes in one second of real time.

Return type: Number

Signature
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.

Parameters
  • start String

    • The start time for the computation, given as an ISO 8601 date string

  • end String

    • The end time for the computation, given as an ISO 8601 date string

Return type: Number The time between the start time and end time

Signature
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.

Parameters
  • deltaTime Number

    • The 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

Signature
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.

Parameters
  • 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

Signature
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.

Parameters
  • isPaused Boolean

    • True 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

Signature
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.

Parameters
  • 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

Signature
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.

Parameters
  • time String | Number

    • The 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

Signature
openspace.time.interpolateTime(time, interpolationDutation)

interpolateTimeRelative

Increment the current simulation time by the specified number of seconds, using interpolation.

Parameters
  • delta Number

    • The 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

Signature
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).

Parameters
  • 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

Signature
openspace.time.interpolateTogglePause(interpolationDuration)

isPaused

Returns whether the simulation time is currently paused or is progressing.

Return type: Boolean

Signature
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

Signature
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

Signature
openspace.time.secondsPerDay()

secondsPerYear

Returns the number of seconds in a Gregorian year, which is equal to 31556952.

Return type: Number

Signature
openspace.time.secondsPerYear()

setDeltaTime

Set the amount of simulation time that happens in one second of real time.

Parameters
  • deltaTime Number

    • The value to set the speed to, in seconds per real time second

Return type: void

Signature
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.

Parameters
  • deltaTime Number[]

    • The list of delta times, given in seconds per real time second. Should only include positive values.

Return type: void

Signature
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

Signature
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.

Parameters
  • isPaused Boolean

    • True if the simulation should be paused, and false otherwise

Return type: void

Signature
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

Signature
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.

Parameters
  • time Number | String

    • The 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

Signature
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

Parameters
  • format String? - Default value: "YYYY MON DDTHR:MN:SC.### ::RND"

Return type: String

Signature
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

Signature
openspace.time.togglePause()

UTC

Returns the current time as an ISO 8601 date string (YYYY-MM-DDTHH:MN:SS).

Return type: String

Signature
openspace.time.UTC()