Typed astronomical time primitives.
The central type is [Time<S, F>] (default F = [J2000s]), where S is a [Scale]
marker (TT, TAI, UTC, UT1, TDB, TCG, TCB) and F is a [TimeFormat]
tag (JD, MJD, [J2000s], [Unix], [GPS]).
tempoch makes a few explicit modeling decisions:
-
[
Time<S, F>] is an instant on a scale-specific axis;Fonly types external views (raw(), conversion targets), not a second storage layout. -
Time arithmetic follows affine rules: instant minus instant yields a duration; shifting an instant by a duration yields another instant.
-
Internal storage is always a compensated
(hi, lo)pair of J2000-based seconds so large epoch values can retain small corrections and sub-second detail. -
JD,MJD,J2000s,Unix, andGPSare conversion targets, not alternate stored encodings. -
UTCkeeps special civil semantics: it is stored as a continuous instant and interpreted through the active UTC-TAI table when civil labels are needed. -
[
Time::new] builds from a raw scalar whenFisInfallibleFormatForScaleforS(NaN panics; ±∞ allowed at rest). POSIX [Unix] instants still use [Time::try_new] / [Time::try_new_with] because decoding depends on leap-second tables. -
[
Time::try_new] / [Time::try_new_with] surface domain decode failures only (UTC policy, leap seconds, …); callers must not pass NaN. -
UTC: civil (chrono) and POSIX ([Unix]);TAI: GPS ([GPS]) -
Unified targets: [
Time::to], [Time::try_to], [Time::to_with]. Prefertry_toorto_withfor [Unix] so positive leap-second instants are rejected when they are not representable as POSIX. -
[
Time::to_j2000s], [Time::reinterpret], and aliases such as [crate::JulianDate]. -
[
JulianDate], [ModifiedJulianDate], [UnixTime], and [GpsTime] implement [Into] into default-tagged [Time<S>] / [Time<UTC>] / [Time<TAI>], so APIs such asPeriod::try_newaccept encoded endpoints without spelling [Time::to_j2000s]. [J2000Seconds<S>] is already [Time<S>]; no conversion needed.
See [constats] for epoch [Time] helpers, day/second scratch constants, and offsets.
Module map
- [
foundation]: shared sealed traits, typed constants, and error types. - [
model]: [Time], scale markers, and conversion targets. - [
format]: external format markers and format conversion traits. encoding: crate-local JD/MJD/J2000/Unix arithmetic helpers.- [
earth]: ΔT, EOP, and [TimeContext] Earth-rotation policy. - [
data]: runtime access to bundled and optionally refreshed time-data tables. - [
period]: interval and period-list algebra. - [
features]: optional serde/tagged/time-instant integration helpers.
Reference modules:
- [
earth::delta_t]: piecewise ΔT (TT - UT1) model and modern tabular segment. - [
earth::eop]: public EOP sampling API over bundled IERS series. - [
earth::context]: immutable time-data snapshot plus conversion policy.