Skip to main content

Scale

Enum Scale 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum Scale {
Show 16 variants TAI = 0, TT = 1, ET = 2, TDB = 3, UTC = 4, UtcSpice = 5, UtcHist = 6, GPS = 7, GST = 8, BDT = 9, QZSS = 10, TCG = 11, TCB = 12, LTC = 13, TCL = 14, Custom = 15,
}
Expand description

Time scales supported by the library.

This #[non_exhaustive] enum defines all time scales that [Dt] can represent. Each [Dt] instance stores its internal time value on the scale indicated by its scale field.

§UTC and Leap Seconds

The library supports three UTC variants:

  • UTC — Modern UTC using the library’s built-in IERS leap second table. Basic functions for run-time loading of leap seconds tables also available.

  • UtcSpice — SPICE-compatible model. Uses a fixed +9 s offset before 1972-01-01 and modern leap seconds afterward.

  • UtcHist — Full historical SOFA model with piecewise linear frequency offsets (“rubber seconds”) from 1961–1972. This variant does not support round-tripping.

§Scale Categories

CategoryScalesPurpose
Atomic / ProperTAI, TT, TDB (alias ET)Continuous atomic time. TAI is the primary internal scale.
Relativistic CoordinateTCG, TCB, TCLTime scales defined in specific relativistic reference frames (GCRS, BCRS, LCRS).
Civil / CoordinatedUTC, UtcSpice, UtcHistReal-world civil time, with support for leap seconds and historical behavior.
GNSS / NavigationGPS, GST, BDT, QZSSTime scales used by satellite navigation constellations.
LunarLTC, TCLLunar time scales based on the LTE440 model (Lu et al. 2025).
SpecialCustomUser-defined or experimental scales.

The reference epoch used for conversions between scales is 2000-01-01 12:00:00 TAI.

§Lunar Time Scales

Both LTC and TCL implement the LTE440 model (Lu et al. 2025):

  • LTC (Coordinated Lunar Time): Operational lunar time for cislunar operations. Applies a secular rate of +56.02 µs per Earth day relative to TT, plus the 13 dominant periodic terms from the model.

  • TCL (Lunar Coordinate Time): IAU-defined relativistic coordinate time in the Lunar Celestial Reference System (LCRS). Includes the secular rate versus TDB, the same periodic terms, and a constant bias calibrated to match the published LTE440 reference value at J2000.0 TDB.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TAI = 0

International Atomic Time (TAI).

§

TT = 1

Terrestrial Time (TT).

A smooth, continuous atomic time scale used in astronomy and dynamics.

§

ET = 2

Ephemeris Time (alias for TDB).

§

TDB = 3

Barycentric Dynamical Time (TDB).

Used for planetary and spacecraft calculations.

§

UTC = 4

Coordinated Universal Time (UTC) using modern leap second rules.

§

UtcSpice = 5

Coordinated Universal Time using the SPICE historical model (fixed +9 s offset before 1972).

§

UtcHist = 6

Coordinated Universal Time using the full historical SOFA model (with “rubber seconds” between 1960–1972).

Round-tripping is not supported.

§

GPS = 7

GPS Time.

The time scale used by the U.S. GPS satellite navigation system.

§

GST = 8

Galileo Time.

The time scale used by Europe’s Galileo satellite navigation system.

§

BDT = 9

BeiDou Time.

The time scale used by China’s BeiDou satellite navigation system.

§

QZSS = 10

QZSS Time.

The time scale used by Japan’s QZSS satellite system (similar to GPS).

§

TCG = 11

Geocentric Coordinate Time (TCG).

A relativistic time scale centered on Earth, used for high-precision work near Earth (e.g. satellite orbits).

§

TCB = 12

Barycentric Coordinate Time (TCB).

A relativistic time scale for the entire solar system.

§

LTC = 13

Coordinated Lunar Time (LTC).

Operational lunar time scale intended for cislunar operations. Based on the LTE440 model.

§

TCL = 14

Lunar Coordinate Time (TCL).

Theoretical relativistic coordinate time at the Moon’s center of mass. Based on the LTE440 model.

§

Custom = 15

Custom / user-defined scale.

Implementations§

Source§

impl Scale

Source

pub const WIRE_SIZE: usize = 1

Size of the canonical wire representation in bytes.

Source

pub const fn is_tai(&self) -> bool

Returns true if this scale is TAI.

Source

pub const fn to_utc(&self) -> Scale

Converts this Scale to UTC.

  • If the scale is already one of the UTC variants including historical UTC then no change occurs.
Source

pub const fn uses_leap_seconds(&self) -> bool

Returns true if this scale accounts for leap seconds (or historical UTC civil time rules).

Source

pub const fn is_gnss(&self) -> bool

Returns true if this scale is based off a GNSS constellation.

Source

pub fn from_abbrev(s: &str) -> Option<Self>

Parse scale from abbreviation. Returns None for any non-ASCII input.

Source

pub const fn abbrev(&self) -> &'static str

Short abbreviation used for formatting / display (e.g. “TAI”, “UTC”, “UtcSpice”).

Source

pub const fn eq(self, other: Self) -> bool

Const-friendly equality comparison.

Source

pub const fn from_u8(v: u8) -> Scale

Attempts to reconstruct a Scale from its wire byte representation.

  • Returns Custom for any value that does not correspond to a known variant.
  • This provides safe deserialization from untrusted sources.
Source

pub const fn to_u8(self) -> u8

Returns the wire representation of this Scale as a single byte.

The returned byte is the repr(u8) discriminant of the enum. This is the canonical on-wire form used by [Dt].

Trait Implementations§

Source§

impl Clone for Scale

Source§

fn clone(&self) -> Scale

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Scale

Source§

impl Debug for Scale

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Scale

Source§

fn default() -> Scale

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Scale

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Scale

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Scale

Source§

impl Hash for Scale

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Scale

Source§

fn cmp(&self, other: &Scale) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Scale

Source§

fn eq(&self, other: &Scale) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Scale

Source§

fn partial_cmp(&self, other: &Scale) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Scale

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Scale

Source§

impl Tsify for Scale

Source§

const DECL: &'static str = "/**\n * Time scales supported by the library.\n *\n * This `#[non_exhaustive]` enum defines all time scales that [`Dt`] can represent.\n * Each [`Dt`] instance stores its internal time value on the scale indicated by\n * its `scale` field.\n *\n * ## UTC and Leap Seconds\n *\n * The library supports three UTC variants:\n *\n * - **`UTC`** \u{2014} Modern UTC using the library\u{2019}s built-in IERS leap second table.\n * Basic functions for run-time loading of leap seconds tables also available.\n *\n * - **`UtcSpice`** \u{2014} SPICE-compatible model. Uses a fixed +9 s offset before\n * 1972-01-01 and modern leap seconds afterward.\n *\n * - **`UtcHist`** \u{2014} Full historical SOFA model with piecewise linear frequency\n * offsets (\\\"rubber seconds\\\") from 1961\u{2013}1972. This variant does **not support\n * round-tripping**.\n *\n * ## Scale Categories\n *\n * | Category | Scales | Purpose |\n * |-----------------------------|---------------------------------|---------|\n * | **Atomic / Proper** | `TAI`, `TT`, `TDB` (alias `ET`) | Continuous atomic time. `TAI` is the primary internal scale. |\n * | **Relativistic Coordinate** | `TCG`, `TCB`, `TCL` | Time scales defined in specific relativistic reference frames (GCRS, BCRS, LCRS). |\n * | **Civil / Coordinated** | `UTC`, `UtcSpice`, `UtcHist` | Real-world civil time, with support for leap seconds and historical behavior. |\n * | **GNSS / Navigation** | `GPS`, `GST`, `BDT`, `QZSS` | Time scales used by satellite navigation constellations. |\n * | **Lunar** | `LTC`, `TCL` | Lunar time scales based on the LTE440 model (Lu et al. 2025). |\n * | **Special** | `Custom` | User-defined or experimental scales. |\n *\n * The reference epoch used for conversions between scales is **2000-01-01 12:00:00 TAI**.\n *\n * ## Lunar Time Scales\n *\n * Both `LTC` and `TCL` implement the **LTE440** model (Lu et al. 2025):\n *\n * - **`LTC`** (Coordinated Lunar Time): Operational lunar time for cislunar operations.\n * Applies a secular rate of **+56.02 \u{b5}s per Earth day** relative to TT, plus the\n * 13 dominant periodic terms from the model.\n *\n * - **`TCL`** (Lunar Coordinate Time): IAU-defined relativistic coordinate time\n * in the Lunar Celestial Reference System (LCRS). Includes the secular rate\n * versus TDB, the same periodic terms, and a constant bias calibrated to match\n * the published LTE440 reference value at J2000.0 TDB.\n */\nexport type Scale = \"TAI\" | \"TT\" | \"ET\" | \"TDB\" | \"UTC\" | \"UtcSpice\" | \"UtcHist\" | \"GPS\" | \"GST\" | \"BDT\" | \"QZSS\" | \"TCG\" | \"TCB\" | \"LTC\" | \"TCL\" | \"Custom\";"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

Source§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

Source§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Auto Trait Implementations§

§

impl Freeze for Scale

§

impl RefUnwindSafe for Scale

§

impl Send for Scale

§

impl Sync for Scale

§

impl Unpin for Scale

§

impl UnsafeUnpin for Scale

§

impl UnwindSafe for Scale

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more