stkcraft_time/lib.rs
1//! NAIF/SPICE-aligned astronomical time scales.
2//!
3//! `stkcraft-time` implements the time-scale model described in the
4//! NAIF *SPICE Time Subsystem Required Reading*. Kernel decimal arithmetic
5//! follows NAIF N0067 NPARSD; see `ATTRIBUTION.md`. The
6//! leap-second data is read from a NAIF Leapseconds Kernel; no leap
7//! second is hard-coded in the conversion logic.
8//!
9//! # Scales
10//!
11//! * [`Calendar`] selects Gregorian, Julian or Mixed calendar arithmetic.
12//! * [`Epoch`] is the canonical internal value: continuous TAI seconds
13//! plus nanoseconds since `2000-01-01T00:00:00 TAI`.
14//! * [`UtcDateTime`] is the civil UTC representation, including
15//! `23:59:60.x` on positive-leap-second days.
16//! * [`Duration`] is an exact signed duration with nanosecond
17//! resolution.
18//! * [`TimeSeries`] iterates uniformly spaced epochs.
19//! * [`convert`] provides UTC, TAI, TT, TDB/ET, GPS and UT1 conversions.
20//! * [`coord`] provides the IAU coordinate scales TCG and TCB.
21//! * [`dtdb`] provides the IAU Fairhead-Bretagnon TDB model.
22//! * [`eop`] holds the IERS Earth Orientation Parameters that UT1 requires.
23//! * [`contract`] separates the default NAIF ET integration contract from
24//! explicitly selected scientific TDB and observer-dependent models.
25//!
26//! # Kernel selection
27//!
28//! Every UTC conversion is a pure function of the leap-second kernel
29//! that is loaded. There is no globally implied kernel and no leap
30//! second is hard-coded in the conversion logic. Load the kernel you
31//! intend to use with [`LeapSecondTable::from_lsk`]; the bundled
32//! [`LeapSecondTable::builtin`] is only a snapshot of `naif0012.tls`.
33//! Two kernels with different `DELTET/DELTA_AT` lists produce different
34//! `TAI - UTC` after the first differing date. [`LeapSecondTable::coverage`]
35//! reports which dates a kernel actually covers.
36//!
37//! # Accuracy
38//!
39//! Internal epoch arithmetic is integer-based, and the nanosecond field
40//! is exactly that: a step of the internal representation, not a claim
41//! of nanosecond accuracy. Real accuracy is bounded by the model and the
42//! data:
43//!
44//! * The leap-second kernel supplies whole-second steps; there is no
45//! sub-second leap data to be had.
46//! * The TT/TDB model (`TDB - TT = K * sin(E)`) is the NAIF model, whose
47//! stated accuracy is about 30 microseconds.
48//! * `ET` is an `f64` by definition, exactly as in SPICE.
49//!
50//! Agreement with CSPICE is a match against a reference engine, not a
51//! physical truth claim.
52//!
53//! # Leap-second policy
54//!
55//! Leap seconds are data, not code. [`LeapSecondTable`] follows the LSK
56//! it was built from. The default [`LeapSecondPolicy::TableDriven`] keeps
57//! the last entry in force; a caller may select
58//! [`LeapSecondPolicy::FrozenAfter`] to model an explicit assumption. The
59//! crate never infers a policy from a date.
60
61#![cfg_attr(not(feature = "std"), no_std)]
62#![forbid(unsafe_code)]
63#![doc(
64 html_logo_url = "https://raw.githubusercontent.com/spacelibres/STKCraft_web/main/public/brand/albatross.png"
65)]
66
67extern crate alloc;
68
69pub mod bdt;
70pub mod calendar;
71pub mod contract;
72pub mod convert;
73pub mod coord;
74pub mod dtdb;
75pub mod duration;
76pub mod eop;
77pub mod epoch;
78pub mod error;
79pub mod format;
80pub mod kernel_date;
81pub mod leap;
82pub mod lsk;
83#[cfg(feature = "mcp")]
84pub mod mcp;
85pub mod sclk;
86pub mod series;
87pub mod tdb;
88pub mod timescale;
89pub mod wgc_gps;
90
91mod dtdb_table;
92mod math;
93mod naif;
94
95#[cfg(kani)]
96mod verification;
97
98pub use bdt::Bdt;
99pub use calendar::Calendar;
100pub use duration::Duration;
101pub use eop::{EopSample, EopSeries, EopTable};
102pub use epoch::{Epoch, UtcDateTime};
103pub use error::TimeError;
104pub use kernel_date::{parse_kernel_date, KernelDate};
105pub use leap::{LeapEntry, LeapSecondPolicy, LeapSecondSource, LeapSecondTable};
106pub use sclk::{SclkKernel, SclkTimeSystem};
107pub use series::TimeSeries;
108pub use timescale::TimeScale;