The J2000 epoch is defined as 2000-01-01T12:00:00 TT (Terrestrial time).

Return the instant corresponding to a J2000 julian date: this is the number of days, and
the fraction of the day since J2000 (`epoch-j2000std/time/astro/epoch-j2000: instant`

) in terrestrial time (`ts-ttstd/time/instant/ts-tt: timescale`

).

`instant-at-j2000std/time/astro/instant-at-j2000: (jd : ddouble) -> instant(zero).time.show == "2000-01-01T11:58:55.816Z"`

`instant-at-j2000std/time/astro/instant-at-j2000: (jd : ddouble) -> instant(zero).time(cal=cal-tt).show == "2000-01-01T12:00:00Z TT"`

.

Return the J2000 julian date for an instant. This is the number of days, and
the fraction of the day since J2000 (`epoch-j2000std/time/astro/epoch-j2000: instant`

) in terrestrial time (`ts-ttstd/time/instant/ts-tt: timescale`

).

`instant(2000,1,1,12,0,0).j2000std/time/astro/j2000: (i : instant) -> ddouble.show == "0.00074287037037"`

`instant(2000,1,1,12,0,0,cal=cal-tt).j2000std/time/astro/j2000: (i : instant) -> ddouble.show == "0"`

.

The TCB (Barycentric coordinate time) time scale. The unit of TCB is the SI second, but in a coordinate reference frame at the barycenter of the solar system.

fun ts-tcb-create( tstdb : timescalestd/time/instant/timescale: V ) : timescalestd/time/instant/timescale: V

Create a new TCB timescale given a TDB timescale (`tstdb`

). The default
`ts-tcbstd/time/astro/ts-tcb: timescale`

uses the default `ts-tdbstd/time/astro/ts-tdb: timescale`

timescale, but if you created
a different TCB time scale (using `ts-tdb-createstd/time/astro/ts-tdb-create: (tdb-minus-tt : (timestamp) -> timespan) -> timescale`

) you can use
this function to create a TCB time scale from it. It computes
TCB from the provided TDB using the IAU 2006 resolution
B3: TDB = TCB -
L_{b} × (JD_{TCB} - T_{0}) × 86400 + TDB_{0}, with T_{0} =
2443144.5003725, L_{b} = 1.55051976772×10^{-8}, TDB_{0} =
-6.55×10^{-5}.

The TCG (Geocentric coordinate time) time scale. The unit of TCG is the SI second in a coordinate reference frame at the center of the Earth.

The TDB (Barycentric dynamical time) time scale
(which can be considered equivalent T_{eph}).

TDB is approximated from TT using an initial set of coefficients by Fairhead & Bretagnon [1] assuming the geo center (longitude and latitude of 0 degrees). See also USNO circular 179 ([2], equation 2.6). The approximation is within 10μs precision in the time span 1600 to 2200 (and probably a bit less).

fun ts-tdb-create( tdb-minus-tt : (timestampstd/time/timestamp/timestamp: V) -> timespanstd/time/timestamp/timespan: V ) : timescalestd/time/instant/timescale: V

Creates a new TDB timescale given a user provided function to calculate TDB-TT.
The default function used for `ts-tdbstd/time/astro/ts-tdb: timescale`

uses the Fairhead & Bretagnon approximation
corrected for JPL planetary masses but assumes the geo center. Use this function
to create a new TDB timescale if you need more precision.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core, std/num/float64std/num/float64, std/num/ddoublestd/num/ddouble, std/time/timestampstd/time/timestamp, std/time/durationstd/time/duration, std/time/instantstd/time/instant, std/time/calendarstd/time/calendar, std/time/utcstd/time/utc, std/time/calendarsstd/time/calendars

## Time scales for astronomy (TT, TCG, TDB, and TCB).

Internally all computations use high precision

`ddoublestd/num/ddouble/ddouble: V`

numbers. The different time scales relate as follows:TAI,`ts-taistd/time/instant/ts-tai: timescale`

,`cal-tai`

: International Atomic Time. The atomic time standard measuring SI seconds on the Earth's geoid.GPS,`ts-gpsstd/time/instant/ts-gps: timescale`

,`cal-gps`

: Global Positioning System time. Runs at the same rate as TAI but with a 19 second offset: GPS = TAI - 19s.UT1,`cal-ut1-load`

: Universal Time: A time scale based on the rotation of the earth where one rotation is 86400 (solar) seconds. Defined to be a linear function of the rotation angle of the Earth. See the`std/time/ut1`

module for more information.UTC,`ts-utc-createstd/time/utc/ts-utc-create: (leaps : leaps-table) -> timescale`

,`cal-utc-load`

: Coordinated Universal Time: A hybrid of UT1 and TAI: uses SI seconds as its unit, but inserts (or deletes) periodically leap seconds in order to stay within 0.9s of UT1. See the`utc`

module for more information.TI,`ts-tistd/time/utc/ts-ti: timescale`

,`cal-isostd/time/calendar/cal-iso: calendar`

: International Time: this was a proposed time scale at the 2004 ITU-R meeting as a replacement of UTC without future leap seconds. In this library, we define TI to match exactly UTC up to the compiler release date (currently 2017) but ignore any possible future leap seconds after that date. This is the preferred time scale in this library as it guarantees deterministic time calculations for any future date, i.e. before 2017-01-01Z, TI == UTC, while after that, TI == TAI - 37s.TT,`ts-ttstd/time/instant/ts-tt: timescale`

,`cal-tt`

: Terrestrial time. This is an ideal time scale defined to run slower at a constant rate from TCG such that TT runs at the same rate as a time scale based on SI seconds on the Earth's geoid. Since TCG is a theoretical time scale, TT can be considered an idealized form of TAI and is currently realized by defining:TT = TAI + 32.184s.

Terrestrial time replaces (and preserves continuity with) the older Terrestrial Dynamic Time (TDT) and Ephemeris Time (ET).

TCG,`ts-tcgstd/time/astro/ts-tcg: timescale`

,`cal-tcg`

: Geocentric Coordinate Time. Theoretical clock using SI seconds in a coordinate reference frame at the center of the Earth. It is in a linear relationship with TT where TCG runs faster than TT at a constant rate. By definition, TCG and TT were equal on 1977-01-01Z. Computed from TT using IAU 1991 recommendation IV (and updated to currently known precision)):TCG = TT + L

_{g}×(JD_{TCG}- 2443144.5003725)×86400, with L_{g}= 6.969290134×10^{-10}.TCB,`ts-tcbstd/time/astro/ts-tcb: timescale`

,`cal-tcb`

: Barycentric Coordinate Time. Theoretical clock using SI seconds in a coordinate reference frame at the gravitational center of the solar system. TCB and TCG are related by a coordinate transformation taking into account relativistic effects (see IAU 2000 resolution B1.5). In the library, instead of transforming TCG, we compute TCB from (the approximated) TDB (`ts-tdbstd/time/astro/ts-tdb: timescale`

) using the IAU 2006 resolution B3:TDB = TCB - L

_{b}× (JD_{TCB}- T_{0}) × 86400 + TDB_{0}, with T_{0}= 2443144.5003725, L_{b}= 1.55051976772×10^{-8}, TDB_{0}= -6.55×10^{-5}.TDB,`ts-tdbstd/time/astro/ts-tdb: timescale`

,`cal-tdb`

: Barycentric Dynamical Time. Defined to run slower at a constant rate from TCB in order to be approximately equal to TT These relativistic corrections ensure a difference to TT of less then 2 milli-seconds and are periodic with an average of zero. In the library, TDB is approximated from TT using an initial set of coefficients by Fairhead & Bretagnon [1] assuming the geo center (longitude and latitude of 0 degrees), and corrected for JPL planetary masses. See also USNO circular 179 [2], equation 2.6). The approximation is within 10μs precision in the time span 1600 to 2200 (and probably a bit less).Note that theoretically the definition of TT is based on TCG which is based on TCB, but in practice we define TT on the basis of an actual clock (TAI) and derive TCG from TT. Moreover, TDB is approximated from TT, and TCB is derived from the approximated TDB.

Since TDB (and in turn TCB) are approximated, it is possible to create your own time scale which uses a potentially more precise approximation using

`ts-tdb-createstd/time/astro/ts-tdb-create: (tdb-minus-tt : (timestamp) -> timespan) -> timescale`

and`ts-tcb-createstd/time/astro/ts-tcb-create: (tstdb : timescale) -> timescale`

.## References

An analytical formula for the time transformation TB-TT. Astronomy and Astrophysics, vol. 229, no. 1, March 1990, p. 240–247. ADS 🔎The IAU Resolutions on Astronomical Reference Systems, Time Scales, and Earth Rotation Models – Explanation and Implementation. USNO Circular 179 🔎Why new time scales?Astronomy and Astrophysics, vol. 265, no. 2, p. 833–838. ADS 🔎.