Skip to main content

celestial_time/scales/
mod.rs

1//! Astronomical time scales.
2//!
3//! Provides implementations of the eight primary time scales used in astronomical
4//! calculations: UTC, TAI, TT, UT1, GPS, TDB, TCB, and TCG.
5//!
6//! # Time Scale Overview
7//!
8//! | Scale | Description | TAI Relationship |
9//! |-------|-------------|------------------|
10//! | TAI | International Atomic Time | Reference |
11//! | UTC | Coordinated Universal Time | TAI - leap seconds |
12//! | TT | Terrestrial Time | TAI + 32.184s |
13//! | UT1 | Earth rotation time | Requires EOP data |
14//! | GPS | GPS satellite time | TAI - 19s |
15//! | TCG | Geocentric Coordinate Time | Linear scale from TT |
16//! | TDB | Barycentric Dynamical Time | TT + periodic terms |
17//! | TCB | Barycentric Coordinate Time | Linear scale from TDB |
18//!
19//! # Usage
20//!
21//! Each time scale is a newtype wrapping a Julian Date. Create instances via
22//! `from_julian_date` or `*_from_calendar` helper functions:
23//!
24//! ```
25//! use celestial_time::{JulianDate, TAI, TT, UTC};
26//! use celestial_time::scales::{tai_from_calendar, tt_from_calendar};
27//!
28//! // From Julian Date
29//! let tai = TAI::from_julian_date(JulianDate::new(2451545.0, 0.0));
30//!
31//! // From calendar components
32//! let tt = tt_from_calendar(2000, 1, 1, 12, 0, 0.0);
33//! ```
34//!
35//! # Conversions
36//!
37//! Convert between scales using traits from the [`conversions`] submodule:
38//!
39//! ```
40//! use celestial_time::{JulianDate, GPS, TAI, TT};
41//! use celestial_time::scales::conversions::{ToTAI, ToTT, ToGPS};
42//!
43//! let tai = TAI::from_julian_date(JulianDate::new(2451545.0, 0.0));
44//! let tt = tai.to_tt().unwrap();
45//! let gps = tai.to_gps().unwrap();
46//! ```
47//!
48//! Some conversions chain through intermediate scales internally. For example,
49//! GPS to TT converts GPS -> TAI -> TT.
50//!
51//! # Precision
52//!
53//! All time scales use split Julian Date storage (jd1, jd2) to preserve
54//! nanosecond precision. When adding offsets, the offset is applied to
55//! the smaller-magnitude component.
56
57pub mod common;
58pub mod conversions;
59pub mod gps;
60pub mod tai;
61pub mod tcb;
62pub mod tcg;
63pub mod tdb;
64pub mod tt;
65pub mod ut1;
66pub mod utc;
67
68pub use gps::gps_from_calendar;
69pub use gps::GPS;
70pub use tai::tai_from_calendar;
71pub use tai::TAI;
72pub use tcb::tcb_from_calendar;
73pub use tcb::TCB;
74pub use tcg::tcg_from_calendar;
75pub use tcg::TCG;
76pub use tdb::tdb_from_calendar;
77pub use tdb::TDB;
78pub use tt::tt_from_calendar;
79pub use tt::TT;
80pub use ut1::ut1_from_calendar;
81pub use ut1::UT1;
82pub use utc::utc_from_calendar;
83pub use utc::UTC;
84
85pub use conversions::{ToTAI, ToTCB, ToTCG, ToTCGFromTCB, ToTDB, ToTT, ToTTFromTDB};