use core::marker::PhantomData;
pub trait Scale: Copy + Clone + core::fmt::Debug + 'static {
const NAME: &'static str;
const DEFINITION: &'static str;
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Reading<S: Scale> {
pub(crate) ns: i128,
pub(crate) _s: PhantomData<S>,
}
impl<S: Scale> Reading<S> {
pub(crate) const fn new(ns: i128) -> Self {
Self {
ns,
_s: PhantomData,
}
}
pub const fn as_nanos(self) -> i128 {
self.ns
}
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Tai;
impl Scale for Tai {
const NAME: &'static str = "TAI";
const DEFINITION: &'static str =
"SI seconds on the geoid, no leap seconds; origin 1958-01-01 00:00:00 TAI (CCSDS).";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Tt;
impl Scale for Tt {
const NAME: &'static str = "TT";
const DEFINITION: &'static str =
"Relativistic coordinate time for Earth geoid; TT = TAI + 32.184 s exactly.";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Tcg;
impl Scale for Tcg {
const NAME: &'static str = "TCG";
const DEFINITION: &'static str =
"Coordinate time of GCRS; TCG−TT = L_G × (JD_TT − 2443144.5) × 86400, L_G = 6.969290134e-10.";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Tcb;
impl Scale for Tcb {
const NAME: &'static str = "TCB";
const DEFINITION: &'static str =
"Coordinate time of BCRS; related to TDB by IAU L_B = 1.550519768e-8.";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Tdb;
impl Scale for Tdb {
const NAME: &'static str = "TDB";
const DEFINITION: &'static str =
"Linearly scaled TCB; TDB−TT is periodic (≈1.6 ms amplitude). Ephemeris time in SPICE.";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Tcl;
impl Scale for Tcl {
const NAME: &'static str = "TCL";
const DEFINITION: &'static str =
"Coordinate time of the Lunar Celestial Reference System (IAU 2024). Origin when TCB reads 1977-01-01 00:00:32.184 at the Moon's center of mass.";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Ltc;
impl Scale for Ltc {
const NAME: &'static str = "LTC";
const DEFINITION: &'static str =
"Provisional: currently realized as TCL (no extra conventional frequency offset). Update when CGPM/BIPM publish the operational convention.";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Gps;
impl Scale for Gps {
const NAME: &'static str = "GPS";
const DEFINITION: &'static str = "TAI − 19 s; epoch 1980-01-06 00:00:00 GPS (= 00:00:00 UTC).";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Gst;
impl Scale for Gst {
const NAME: &'static str = "GST";
const DEFINITION: &'static str =
"Galileo System Time; TAI − 19 s (modulo GST-GPS small offset, treated as 0 here).";
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Bdt;
impl Scale for Bdt {
const NAME: &'static str = "BDT";
const DEFINITION: &'static str = "BeiDou Time; TAI − 33 s; epoch 2006-01-01.";
}