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:
- Getting started: installation, unit conventions and recommended practices
- API reference for
@interstellar-tools/temporal: every export, with formulas, parameters and examples
Installation
- Node.js version 22.12.0 or higher
- ES modules;
require()needs Node 22.12 or later
shell
npm i --save @interstellar-tools/temporalVariables
| Variable | Description |
|---|---|
| NORMALIZE_TEMPORAL_UNIT | Lookup table that normalizes user-facing time unit aliases (and the canonical symbols themselves) to a single, canonical TemporalUnitType. |
| SECONDS_PER | Seconds-per-unit lookup for all canonical TemporalUnitType symbols. |
Functions
| Function | Description |
|---|---|
| convertTemporalUnit | Convert a temporal duration between any two TemporalUnitType units or their aliases. |
| normalizeTemporalUnit | Normalize a user-provided temporal unit string into a canonical TemporalUnitType. |
Mars time
| Function | Description |
|---|---|
| coordinatedMarsTime | Coordinated Mars Time (MTC): the mean solar time at Mars's prime meridian, Airy-0, in hours, like UTC is at Greenwich. |
| marsLocalMeanSolarTime | The local mean solar time on Mars at a longitude, in hours: Coordinated Mars Time plus the east longitude in hours, 15° to the hour. |
| marsSolDate | The Mars Sol Date of a moment: a continuous count of sols, Mars's mean solar days, like the Julian date for Earth. |
| missionSol | The mission sol at a landing site: the number of the sol a rover is on, counted from its landing. |
Time scales
| Function | Description |
|---|---|
| dateFromJulianDate | The UTC Date of a Julian date in a time scale: the inverse of julianDate. |
| julianDate | The 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. |
| modifiedJulianDate | The 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. |
| taiMinusUtc | TAI − UTC, in s, at a moment: the number of leap seconds so far, plus the 10 s UTC started with in 1972. |