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, UTCSofa = 6, GPS = 7, GST = 8, BDT = 9, QZSS = 10, TCG = 11, TCB = 12, LTC = 13, TCL = 14, Custom = 15,
}
Expand description

Time scales supported for conversions.

This #[non_exhaustive] enum defines the complete set of time scales used by the library for representing instants (Epoch) and performing conversions between them.

It covers atomic, dynamical, coordinate, civil/coordinated, GNSS, and emerging lunar scales, plus a Custom variant for mission-specific or experimental use.

§Overview

Time scales fall into several broad categories:

  • Atomic / proper time scales: TAI (basis), TT, TDB/ET — continuous and suitable for internal representation and dynamical modeling.
  • Coordinate time scales (relativistic): TCG, TCB, TCL — defined in specific reference frames (GCRS, BCRS, LCRS). Ideal for ephemeris integration and high-accuracy modeling; not directly realized by clocks.
  • Coordinated / civil scales: UTC (atomic time with leap seconds inserted to keep it close to UT1), UT1 (observed Earth rotation angle — does not use leap seconds), and the lunar operational scale LTC (uses defined secular rate offsets for traceability and cislunar operations).
  • GNSS / navigation scales: GPS, GST, BDT, QZSS — tied to specific satellite constellations.
  • Custom: Fallback for custom scales.

The default variant is [TAI], which serves as the internal canonical representation in many high-precision time libraries because it is continuous and forms the foundation for most conversions.

The library’s epoch when performing conversions between all scales is 2000-01-01 noon.

§Lunar Time Scales (LTC and TCL)

The library provides high-accuracy implementations of both lunar time scales based on the LTE440 model (Lu et al. 2025, A&A 704, A76):

  • [LTC] (Coordinated Lunar Time): Applies the secular rate offset (L_M ≈ +56.02 µs/day) plus the 13 dominant periodic terms from LTE440. Conversions use fixed-point iteration for numerical stability. Achieves sub-nanosecond accuracy (< 0.15 ns before 2050) when the periodic terms are included.

  • [TCL] (Lunar Coordinate Time): IAU-defined relativistic coordinate time in the LCRS. The implementation includes the secular rate vs TDB, the same LTE440 periodic terms, and a constant bias calibrated so that the model exactly reproduces the official LTE440 reference value at J2000.0 TDB. Inverse conversion also uses fixed-point iteration.

See the documentation on the individual variants for rates, historical models, and conversion notes.

§Features

  • serde — full serialization/deserialization support.
  • js — TypeScript definitions via tsify.

§Non-exhaustive

The enum is marked #[non_exhaustive] so new scales can be added in future minor versions without breaking changes.

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

TAI is the representation of an Epoch internally.

§

TT = 1

Terrestrial Time (TT) (previously called Terrestrial Dynamical Time (TDT)).

§

ET = 2

Ephemeris Time as defined by NASA/NAIF SPICE (identical to TDB).

§

TDB = 3

Barycentric Dynamical Time (TDB) — SPICE ephemeris time (ET is an alias for this).

§

UTC = 4

Universal Coordinated Time using modern IERS leap second rules.

§

UTCSpice = 5

Universal Coordinated Time using the SPICE historical model (fixed +9 s offset against TAI for all dates before 1972-01-01).

§

UTCSofa = 6

Universal Coordinated Time using the full SOFA historical model (varying fractional “rubber second” offsets from 1960–1971).

§

GPS = 7

GPS Time scale whose reference epoch is UTC midnight between 05 January and 06 January 1980.

§

GST = 8

Galileo Time scale.

§

BDT = 9

BeiDou Time scale.

§

QZSS = 10

QZSS Time scale has the same properties as GPS but with dedicated clocks.

§

TCG = 11

Geocentric Coordinate Time (TCG) – relativistic coordinate time in the Geocentric Celestial Reference System (GCRS).

§

TCB = 12

Barycentric Coordinate Time (TCB) – relativistic coordinate time in the Barycentric Celestial Reference System (BCRS).

§

LTC = 13

Coordinated Lunar Time (LTC) – NASA’s operational lunar time scale for Artemis and cislunar operations (based on the NIST/Ashby & Patla relativistic framework).

Implements the full LTE440 model (Lu et al. 2025):

  • Secular rate: +56.02 µs per Earth day (L_M = 6.48378 × 10^{-10}) relative to terrestrial time.
  • Plus the 13 dominant periodic terms (> 1 µs amplitude) from the LTE440 ephemeris.
§

TCL = 14

Lunar Coordinate Time (TCL) – IAU-defined (2024 Resolution II) relativistic coordinate time in the Lunar Celestial Reference System (LCRS).

Directly analogous to TCG. This is the theoretical coordinate time at the Moon’s center of mass.

The implementation follows the LTE440 model (Lu et al. 2025):

  • Secular rate vs TDB (L_D^M).
  • The same 13-term LTE440 periodic series used for LTC.
  • A constant bias (TCL_TDB_BIAS_SPAN) calibrated so the model exactly reproduces the published LTE440 reference value at J2000.0 TDB.
§

Custom = 15

Custom / user-defined type.

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) -> Self

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) -> Self

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_wire_byte(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] and [ClockModel].

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 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 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 Tsify for Scale

Source§

const DECL: &'static str = "/**\n * Time scales supported for conversions.\n *\n * This `#[non_exhaustive]` enum defines the complete set of time scales used by\n * the library for representing instants (`Epoch`) and performing conversions\n * between them.\n *\n * It covers atomic, dynamical, coordinate, civil/coordinated, GNSS, and emerging\n * lunar scales, plus a `Custom` variant for mission-specific or experimental use.\n *\n * ## Overview\n *\n * Time scales fall into several broad categories:\n *\n * - **Atomic / proper time scales**: TAI (basis), TT, TDB/ET \u{2014} continuous and\n * suitable for internal representation and dynamical modeling.\n * - **Coordinate time scales** (relativistic): TCG, TCB, **TCL** \u{2014} defined in\n * specific reference frames (GCRS, BCRS, LCRS). Ideal for ephemeris\n * integration and high-accuracy modeling; not directly realized by clocks.\n * - **Coordinated / civil scales**: UTC (atomic time with leap seconds inserted\n * to keep it close to UT1), **UT1** (observed Earth rotation angle \u{2014} does **not**\n * use leap seconds), and the lunar operational scale **LTC** (uses defined\n * secular rate offsets for traceability and cislunar operations).\n * - **GNSS / navigation scales**: GPS, GST, BDT, QZSS \u{2014} tied to specific\n * satellite constellations.\n * - **Custom**: Fallback for custom scales.\n *\n * The default variant is [`TAI`], which serves as the internal canonical\n * representation in many high-precision time libraries because it is\n * continuous and forms the foundation for most conversions.\n *\n * The library\\\'s epoch when performing conversions between all scales is\n * 2000-01-01 noon.\n *\n * ## Lunar Time Scales (LTC and TCL)\n *\n * The library provides high-accuracy implementations of both lunar time scales\n * based on the **LTE440** model (Lu et al. 2025, A&A 704, A76):\n *\n * - [`LTC`] (Coordinated Lunar Time): Applies the secular rate offset\n * (`L_M \u{2248} +56.02 \u{b5}s/day`) **plus** the 13 dominant periodic terms from LTE440.\n * Conversions use fixed-point iteration for numerical stability.\n * Achieves sub-nanosecond accuracy (< 0.15 ns before 2050) when the periodic\n * terms are included.\n *\n * - [`TCL`] (Lunar Coordinate Time): IAU-defined relativistic coordinate time\n * in the LCRS. The implementation includes the secular rate vs TDB, the same\n * LTE440 periodic terms, and a constant bias calibrated so that the model\n * exactly reproduces the official LTE440 reference value at J2000.0 TDB.\n * Inverse conversion also uses fixed-point iteration.\n *\n * See the documentation on the individual variants for rates, historical\n * models, and conversion notes.\n *\n * ## Features\n *\n * - `serde` \u{2014} full serialization/deserialization support.\n * - `js` \u{2014} TypeScript definitions via `tsify`.\n *\n * ## Non-exhaustive\n *\n * The enum is marked `#[non_exhaustive]` so new scales can be added in\n * future minor versions without breaking changes.\n */\nexport type Scale = \"TAI\" | \"TT\" | \"ET\" | \"TDB\" | \"UTC\" | \"UTCSpice\" | \"UTCSofa\" | \"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,

Source§

impl Copy for Scale

Source§

impl Eq for Scale

Source§

impl StructuralPartialEq for Scale

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<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: 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: ErasableGeneric<Repr = Self::Repr>,

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

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