satellite_datetime/
scale.rs1use core::marker::PhantomData;
4
5pub trait Scale: Copy + Clone + core::fmt::Debug + 'static {
7 const NAME: &'static str;
9 const DEFINITION: &'static str;
11}
12
13#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct Reading<S: Scale> {
16 pub(crate) ns: i128,
17 pub(crate) _s: PhantomData<S>,
18}
19
20impl<S: Scale> Reading<S> {
21 pub(crate) const fn new(ns: i128) -> Self {
22 Self {
23 ns,
24 _s: PhantomData,
25 }
26 }
27
28 pub const fn as_nanos(self) -> i128 {
30 self.ns
31 }
32}
33
34#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
36pub struct Tai;
37impl Scale for Tai {
38 const NAME: &'static str = "TAI";
39 const DEFINITION: &'static str =
40 "SI seconds on the geoid, no leap seconds; origin 1958-01-01 00:00:00 TAI (CCSDS).";
41}
42
43#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
45pub struct Tt;
46impl Scale for Tt {
47 const NAME: &'static str = "TT";
48 const DEFINITION: &'static str =
49 "Relativistic coordinate time for Earth geoid; TT = TAI + 32.184 s exactly.";
50}
51
52#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
54pub struct Tcg;
55impl Scale for Tcg {
56 const NAME: &'static str = "TCG";
57 const DEFINITION: &'static str =
58 "Coordinate time of GCRS; TCG−TT = L_G × (JD_TT − 2443144.5) × 86400, L_G = 6.969290134e-10.";
59}
60
61#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
63pub struct Tcb;
64impl Scale for Tcb {
65 const NAME: &'static str = "TCB";
66 const DEFINITION: &'static str =
67 "Coordinate time of BCRS; related to TDB by IAU L_B = 1.550519768e-8.";
68}
69
70#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
72pub struct Tdb;
73impl Scale for Tdb {
74 const NAME: &'static str = "TDB";
75 const DEFINITION: &'static str =
76 "Linearly scaled TCB; TDB−TT is periodic (≈1.6 ms amplitude). Ephemeris time in SPICE.";
77}
78
79#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
81pub struct Tcl;
82impl Scale for Tcl {
83 const NAME: &'static str = "TCL";
84 const DEFINITION: &'static str =
85 "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.";
86}
87
88#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
90pub struct Ltc;
91impl Scale for Ltc {
92 const NAME: &'static str = "LTC";
93 const DEFINITION: &'static str =
94 "Provisional: currently realized as TCL (no extra conventional frequency offset). Update when CGPM/BIPM publish the operational convention.";
95}
96
97#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
99pub struct Gps;
100impl Scale for Gps {
101 const NAME: &'static str = "GPS";
102 const DEFINITION: &'static str = "TAI − 19 s; epoch 1980-01-06 00:00:00 GPS (= 00:00:00 UTC).";
103}
104
105#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
107pub struct Gst;
108impl Scale for Gst {
109 const NAME: &'static str = "GST";
110 const DEFINITION: &'static str =
111 "Galileo System Time; TAI − 19 s (modulo GST-GPS small offset, treated as 0 here).";
112}
113
114#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
116pub struct Bdt;
117impl Scale for Bdt {
118 const NAME: &'static str = "BDT";
119 const DEFINITION: &'static str = "BeiDou Time; TAI − 33 s; epoch 2006-01-01.";
120}