Skip to content

Documentation / @interstellar-tools/temporal

@interstellar-tools/temporal ​

Time and epoch utilities for space applications, from attoseconds to gigayears, with unit normalisation and conversion that the rest of the stack builds on, and Julian dates on the UTC, TAI, TT, UT1, TDB and GPS time scales, with leap seconds.

Documentation ​

The full documentation lives at phun-ky.net/interstellar-tools:

Installation ​

  • Node.js version 22.12.0 or higher
  • ES modules; require() needs Node 22.12 or later
npm
shell
npm i --save @interstellar-tools/temporal

Variables ​

VariableDescription
NORMALIZE_TEMPORAL_UNITLookup table that normalizes user-facing time unit aliases (and the canonical symbols themselves) to a single, canonical TemporalUnitType.
SECONDS_PERSeconds-per-unit lookup for all canonical TemporalUnitType symbols.

Functions ​

FunctionDescription
convertTemporalUnitConvert a temporal duration between any two TemporalUnitType units or their aliases.
normalizeTemporalUnitNormalize a user-provided temporal unit string into a canonical TemporalUnitType.

Mars time ​

FunctionDescription
coordinatedMarsTimeCoordinated Mars Time (MTC): the mean solar time at Mars's prime meridian, Airy-0, in hours, like UTC is at Greenwich.
marsLocalMeanSolarTimeThe local mean solar time on Mars at a longitude, in hours: Coordinated Mars Time plus the east longitude in hours, 15° to the hour.
marsSolDateThe Mars Sol Date of a moment: a continuous count of sols, Mars's mean solar days, like the Julian date for Earth.
missionSolThe mission sol at a landing site: the number of the sol a rover is on, counted from its landing.

Time scales ​

FunctionDescription
dateFromJulianDateThe UTC Date of a Julian date in a time scale: the inverse of julianDate.
julianDateThe Julian date of a moment, in a time scale: the number of days since noon on 1 January 4713 BC, counted on that scale's clock.
modifiedJulianDateThe modified Julian date of a moment, in a time scale: the Julian date minus 2 400 000.5, so days start at midnight and MJD 0 is 1858-11-17.
taiMinusUtcTAI − UTC, in s, at a moment: the number of leap seconds so far, plus the 10 s UTC started with in 1972.