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.

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

§UTC Variants and Leap Seconds

The library supports three UTC variants:

  • UTC — Modern UTC using the built-in IERS leap second table (recommended for most uses).
  • UtcSpice — SPICE-compatible model with a fixed +9 s offset before 1972-01-01.
  • UtcHist — Historical SOFA model with piecewise linear offsets (“rubber seconds”) from 1961–1972. Round-tripping is not supported for this variant.

§Supported Time Scales

ScaleDescription
TAIInternational Atomic Time. The primary internal continuous atomic time scale.
TTTerrestrial Time. Smooth atomic time used in astronomy and dynamics (TAI + 32.184 s).
ETEphemeris Time using the NAIF/SPICE simplified model (~30 µs accuracy). Matches NASA/NAIF SPICE for interoperability. Use TDB for higher-fidelity.
TDBBarycentric Dynamical Time. High-fidelity relativistic ephemeris time (DE440/LTE440 + VSOP2013 tuned model).
UTCCoordinated Universal Time using modern IERS leap second rules.
UtcSpiceCoordinated Universal Time using the SPICE historical model (fixed +9 s offset before 1972-01-01).
UtcHistCoordinated Universal Time using the historical SOFA model with “rubber seconds” (1961–1972). Round-tripping is not supported.
GPSGPS Time (used by the U.S. GPS navigation constellation).
GSTGalileo Time (used by Europe’s Galileo navigation system).
BDTBeiDou Time (used by China’s BeiDou navigation system).
QZSSQZSS Time (used by Japan’s QZSS satellite system).
TCGGeocentric Coordinate Time. Relativistic time scale in the GCRS (Earth-centered).
TCBBarycentric Coordinate Time. Relativistic time scale in the BCRS (solar-system barycenter).
LTCCoordinated Lunar Time. Operational lunar time for cislunar use based on the LTE440 model.
TCLLunar Coordinate Time. IAU relativistic coordinate time in the LCRS based on the LTE440 model.
CustomUser-defined or experimental time scale.

§Lunar Time Scales (LTC / TCL)

Both LTC and TCL are based on the LTE440 model (Lu et al. 2025):

  • LTC (Coordinated Lunar Time) — Intended for operational cislunar use. Applies a secular rate of +56.02 µs/day relative to TT plus the dominant periodic terms.
  • TCL (Lunar Coordinate Time) — Theoretical IAU relativistic coordinate time at the Moon’s center of mass. Includes the secular rate versus TDB, periodic terms, and a J2000 bias calibrated to published LTE440 values.

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 (TAI + 32.184 s constant offset).

§

ET = 2

Ephemeris Time (NAIF/SPICE simplified model).

Uses the official NAIF simplified single-term model for interoperability with NASA/NAIF SPICE (~30 µs accuracy). For higher-fidelity relativistic ephemeris calculations, use TDB instead.

§

TDB = 3

Barycentric Dynamical Time (TDB).

High-fidelity relativistic ephemeris time tuned to DE440/LTE440 + VSOP2013. Used for precise planetary and spacecraft trajectory 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-01-01).

§

UtcHist = 6

Coordinated Universal Time using the historical SOFA model (with “rubber seconds” between 1961–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 Format for Scale

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
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`](struct.Dt.html) can represent.\n * Each [`Dt`](struct.Dt.html) instance stores its internal time value on the scale indicated by\n * its `scale` field.\n *\n * The reference epoch used for conversions between scales is **2000-01-01 12:00:00 TAI**.\n *\n * ## UTC Variants and Leap Seconds\n *\n * The library supports three UTC variants:\n *\n * - **`UTC`** \u{2014} Modern UTC using the built-in IERS leap second table (recommended for most uses).\n * - **`UtcSpice`** \u{2014} SPICE-compatible model with a fixed +9 s offset before 1972-01-01.\n * - **`UtcHist`** \u{2014} Historical SOFA model with piecewise linear offsets (\u{201c}rubber seconds\u{201d}) from 1961\u{2013}1972.\n * Round-tripping is **not supported** for this variant.\n *\n * ## Supported Time Scales\n *\n * | Scale | Description |\n * |-------------|-------------|\n * | `TAI` | International Atomic Time. The primary internal continuous atomic time scale. |\n * | `TT` | Terrestrial Time. Smooth atomic time used in astronomy and dynamics (TAI + 32.184 s). |\n * | `ET` | Ephemeris Time using the **NAIF/SPICE simplified model** (~30 \u{b5}s accuracy). Matches NASA/NAIF SPICE for interoperability. Use `TDB` for higher-fidelity. |\n * | `TDB` | Barycentric Dynamical Time. High-fidelity relativistic ephemeris time (DE440/LTE440 + VSOP2013 tuned model). |\n * | `UTC` | Coordinated Universal Time using modern IERS leap second rules. |\n * | `UtcSpice` | Coordinated Universal Time using the SPICE historical model (fixed +9 s offset before 1972-01-01). |\n * | `UtcHist` | Coordinated Universal Time using the historical SOFA model with \u{201c}rubber seconds\u{201d} (1961\u{2013}1972). Round-tripping is not supported. |\n * | `GPS` | GPS Time (used by the U.S. GPS navigation constellation). |\n * | `GST` | Galileo Time (used by Europe\u{2019}s Galileo navigation system). |\n * | `BDT` | BeiDou Time (used by China\u{2019}s BeiDou navigation system). |\n * | `QZSS` | QZSS Time (used by Japan\u{2019}s QZSS satellite system). |\n * | `TCG` | Geocentric Coordinate Time. Relativistic time scale in the GCRS (Earth-centered). |\n * | `TCB` | Barycentric Coordinate Time. Relativistic time scale in the BCRS (solar-system barycenter). |\n * | `LTC` | Coordinated Lunar Time. Operational lunar time for cislunar use based on the LTE440 model. |\n * | `TCL` | Lunar Coordinate Time. IAU relativistic coordinate time in the LCRS based on the LTE440 model. |\n * | `Custom` | User-defined or experimental time scale. |\n *\n * ## Lunar Time Scales (LTC / TCL)\n *\n * Both `LTC` and `TCL` are based on the **LTE440** model (Lu et al. 2025):\n *\n * - `LTC` (Coordinated Lunar Time) \u{2014} Intended for operational cislunar use. Applies a secular rate of **+56.02 \u{b5}s/day** relative to TT plus the dominant periodic terms.\n * - `TCL` (Lunar Coordinate Time) \u{2014} Theoretical IAU relativistic coordinate time at the Moon\u{2019}s center of mass. Includes the secular rate versus TDB, periodic terms, and a J2000 bias calibrated to published LTE440 values.\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