Skip to main content

Module coord

Module coord 

Source
Expand description

Strongly-typed raw time coordinates.

Coord<S, F> is an affine point in time on scale S (TT, TAI, UTC, …) in format F (JD, MJD, J2000 seconds, Unix, GPS, …). Offset<S, F> is its associated displacement vector.

Together, these two types let the crate name and type-check values that used to circulate as bare qtty::Day / qtty::Second. For example, Coord<TT, JD> is statically distinct from Coord<UTC, JD>, so the compiler now rejects mistakes like reusing a UTC-axis Julian Date as a TT one.

The type parameter order <S, F> (Scale first, Format second) mirrors EncodedTime<S, F> for consistency.

§Affine semantics

  • Coord - Coord -> Offset
  • Coord + Offset -> Coord
  • Coord - Offset -> Coord
  • Offset + Offset -> Offset
  • Offset - Offset -> Offset
  • -Offset -> Offset

Adding two coordinates is intentionally not modeled — averaging or summing instants in the same coordinate system is not a primitive operation here.

§Interop with EncodedTime

Coord<S, F> and EncodedTime<S, F> carry the same information (a typed quantity, a scale, and a format). Conversion in both directions is zero-cost via From / Into. Use Coord for raw coordinate arithmetic and constants; use EncodedTime for the high-level to_time* / to::<Target>() conversion machinery.

Structs§

Coord
A typed time coordinate on scale S in format F.
Offset
A typed displacement between two Coord<S, F> values.