Skip to main content

satellite_datetime/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3//! Experimental timescales for spacecraft, the Moon, and the solar system.
4//!
5//! **Status: 0.1 work-in-progress.** APIs may break. Not flight-qualified.
6//! Lunar TCL is origin-only (no IAU periodic series). Time zones are a seven-zone
7//! subset, not the IANA tzdb. Coordinated Lunar Time (LTC) is provisional.
8//! UT1/DUT1 is a pinned IERS C04 table (not CIP/CIO polar motion).
9//!
10//! An instant is not a calendar. The core stores TAI nanoseconds since
11//! 1958-01-01 00:00:00 TAI. UTC leap seconds, DST, sols, and lunar clocks are
12//! projections of that value. There is no `now()`; inject a clock.
13//!
14//! **Cost model (`earth` feature):** TAI arithmetic is the hot core. Reconstructing
15//! civil UTC from an arbitrary [`Instant`] (`to_utc`) is a convenience search.
16//! Same-day telemetry should pin a [`UtcDay`] and use [`dut1_at`] / [`era_at_utc`].
17//!
18//! ```
19//! use satellite_datetime::{Duration, Instant};
20//!
21//! let t = Instant::TAI_EPOCH
22//!     .checked_add(Duration::from_seconds(1))
23//!     .unwrap();
24//! assert_eq!(t.as_tai_nanos(), 1_000_000_000);
25//! ```
26//!
27//! Enable `--no-default-features` for the satellite (`no_std`, no allocator) profile.
28//!
29//! API docs: <https://docs.rs/satellite-datetime>. Locally: `cargo doc --open`.
30
31mod constants;
32pub mod duration;
33pub mod error;
34pub mod instant;
35pub mod julian;
36pub mod scale;
37
38#[cfg(feature = "bodies")]
39#[cfg_attr(docsrs, doc(cfg(feature = "bodies")))]
40pub mod bodies;
41#[cfg(feature = "ccsds")]
42#[cfg_attr(docsrs, doc(cfg(feature = "ccsds")))]
43pub mod ccsds;
44#[cfg(feature = "earth")]
45#[cfg_attr(docsrs, doc(cfg(feature = "earth")))]
46pub mod earth;
47#[cfg(feature = "gnss")]
48#[cfg_attr(docsrs, doc(cfg(feature = "gnss")))]
49pub mod gnss;
50#[cfg(feature = "lunar")]
51#[cfg_attr(docsrs, doc(cfg(feature = "lunar")))]
52pub mod lunar;
53#[cfg(feature = "mars")]
54#[cfg_attr(docsrs, doc(cfg(feature = "mars")))]
55pub mod mars;
56#[cfg(feature = "tz")]
57#[cfg_attr(docsrs, doc(cfg(feature = "tz")))]
58pub mod tz;
59
60pub use constants::{
61    BDT_MINUS_TAI, GPS_MINUS_TAI, IAU_1977_JD, J2000_JD, LTC_DEFINITION_STATUS,
62    LUNAR_SURFACE_MINUS_TT_PER_DAY, L_B, L_G, NS_PER_DAY, NS_PER_SEC, TAI_1977_NS, TAI_EPOCH_JD,
63    TAI_EPOCH_MJD, TAI_EPOCH_UNIX_DAYS,
64};
65pub use duration::Duration;
66pub use error::{Error, Result};
67pub use instant::Instant;
68pub use julian::{civil_from_unix_days, unix_days_from_civil, JulianDate};
69pub use scale::{Bdt, Gps, Gst, Ltc, Reading, Scale, Tai, Tcb, Tcg, Tcl, Tdb, Tt};
70
71#[cfg(feature = "earth")]
72#[cfg_attr(docsrs, doc(cfg(feature = "earth")))]
73pub use earth::{
74    dut1_at, era_at_utc, format_rfc3339, gmst_mean_at_utc, julian_ut1_at, parse_rfc3339, utc_mjd,
75    CivilUtc, UtcContext, UtcDay,
76};