Expand description
Time scales, leap seconds, calendar dates, and the time manager.
Pure-Rust port of JEOD’s models/environment/time/. The crate models the
standard astronomical and engineering time scales (TAI, UTC, UT1, TT,
TDB, GPS, GMST), the leap-second table that ties UTC to TAI, and the
per-simulation user-defined epoch (UDE) and mission-elapsed time (MET)
that mission code typically logs against.
§Public surface
TimeManagerandTimeScaleId— the orchestrator that owns the currently registered time scales and answers conversions between them. Mirrors JEOD’sTimeManager.SimulationTime— the resource the integration loop advances each step; downstream consumers (gravity, ephemeris, atmosphere) read from it rather than tracking their own clocks.DynamicTime— the dynamics-frame time state passed through the integrator.LeapSecondTable— parser/lookup for JEOD’smodels/environment/time/data/Leap_Second.dat. Required for any simulation that hits a UTC↔TAI conversion.- Calendar / epoch types:
CalendarDateandUTC_EPOCH_TAI_TJTfromtime_utc,UserDefinedEpochfromtime_ude,MissionElapsedTimefromtime_met,GpsTimeComponentsandTAI_GPS_OFFSETfromtime_gps, plus theepochmodule. - Per-pair time converters:
time_converter_tai_tdb,time_converter_tai_tt, andtime_converter_ut1_gmsteach port one of JEOD’sTimeConverter_*classes. GMST in particular drives Earth’s body-fixed rotation inastrodyn_frames.
JEOD source: models/environment/time/ (and the
models/environment/time/data/ subdirectory for Leap_Second.dat). Pure
Rust, zero Bevy dependency.
§Example
Build a calendar date and round-trip it through the truncated Julian representation that the per-scale converters consume internally:
use astrodyn_time::time_utc::{calendar_to_tjt, tjt_to_calendar, CalendarDate};
let cal = CalendarDate::new(2025, 1, 1, 0, 0, 0.0);
let tjt = calendar_to_tjt(&cal);
let back = tjt_to_calendar(tjt);
assert_eq!(back.year, cal.year);
assert_eq!(back.month, cal.month);
assert_eq!(back.day, cal.day);Re-exports§
pub use leap_second::LeapSecondTable;pub use simulation_time::SimulationTime;pub use time_dyn::DynamicTime;pub use time_gps::GpsTimeComponents;pub use time_gps::TAI_GPS_OFFSET;pub use time_manager::TimeManager;pub use time_manager::TimeScaleId;pub use time_met::MissionElapsedTime;pub use time_ude::UserDefinedEpoch;pub use time_utc::CalendarDate;pub use time_utc::UTC_EPOCH_TAI_TJT;pub use epoch::*;
Modules§
- epoch
- Standard astronomical epochs and JD ↔ MJD ↔ TJT conversions.
- leap_
second LeapSecondTable— TAI ↔ UTC leap-second lookup.- simulation_
time SimulationTime— the per-step time-state resource that the integration loop advances each step and that downstream consumers (gravity, ephemeris, atmosphere) read from.- time_
converter_ tai_ tdb - TAI ↔ TDB time-scale conversion.
- time_
converter_ tai_ tt - TAI ↔ TT time-scale conversion (constant
32.184s offset). - time_
converter_ ut1_ gmst - UT1 → GMST conversion (Greenwich Mean Sidereal Time).
- time_
dyn - DYN — Dynamic Time scale.
- time_
gps - GPS time scale — constant offset from TAI plus GPS week/day decomposition.
- time_
manager - Time Manager — dependency-ordered conversion between time scales.
- time_
met - MET — Mission Elapsed Time.
- time_
ude - UDE — User-Defined Epoch time scale.
- time_
utc - UTC time scale — calendar representation and TAI↔UTC conversion.
Structs§
- Body
Attitude - RootInertial → body attitude of vehicle
V, witnessed unit-norm and scalar-first / left-transformation (JEOD canonical). - Body
Frame - Body (CoM-centered) frame of vehicle
V. Rotates with the vehicle. - Earth
- Planet marker for Earth.
- Ecef
- Earth-centered Earth-fixed frame (ITRF-like). Rotates with Earth.
- Frame
Transform - Proper rotation taking vectors expressed in
Fromto the same vectors expressed inTo. - GMST
- Greenwich Mean Sidereal Time (angle, but seconds-ized by convention).
- GPS
- GPS Time (TAI − 19 s).
- Grav
Param - Gravitational parameter μ = GM tagged with the source planet
P. - Harmonic
Degree - Spherical-harmonic degree or order index. Unitless ordinal.
- Inertia
Tensor - Mass moment of inertia tensor (
kg·m²) expressed in frameF. - Integ
Origin - The integration-frame origin: position and velocity of the integration-frame origin expressed in root-inertial coordinates.
- Integration
Frame - A body’s integration frame — a non-rotating quasi-inertial frame whose origin generally differs from the root inertial origin.
- Left
Transform r' = q r q⁻¹— the JEOD convention.- Lvlh
- Local Vertical / Local Horizontal frame relative to chief vehicle
Chief. Z axis points planet-ward; Y opposes orbital angular momentum; X completes the right-handed triad (approximately along-track in near-circular orbits). - Mars
- Planet marker for Mars.
- Mass
Node - Mass-tree wildcard inertial-flavor frame for kinematic-propagation scratch state.
- Moon
- Planet marker for Moon.
- Ned
- North-East-Down topocentric frame relative to chief vehicle
Chief. - Normalized
Quat - A quaternion witnessed to have unit norm at construction time.
- Planet
Fixed - Planet-fixed frame for any planet
P. Rotates with that planet. - Planet
Inertial - A particular planet’s inertial (non-rotating, J2000-aligned) frame, centered at the planet’s CoM.
- Qty3
- Componentwise 3-vector: each of
x,y,zcarries the dimensionD, and the whole vector carries the frame tagF. - Quat
- Quaternion tagged with its storage layout and transformation convention.
- Right
Transform r' = q⁻¹ r q— the opposite of JEOD; common in many textbooks.- Root
Inertial - The simulation’s root inertial frame — the unique inertial node at the top of the frame tree.
- Scalar
First - Storage layout
[q0, q1, q2, q3]whereq0is the scalar part (JEOD). - Scalar
Last - Storage layout
[x, y, z, w]wherewis the scalar part (glam). - Seconds
Since - Seconds elapsed in the named time scale, measured from that scale’s epoch.
- Self
Planet - Phantom marker for “this entity’s own planet” — used by ECS adapters
whose per-entity components carry
PlanetFixed<P>phantoms but whose planet identity is determined at runtime by the entity itself. - SelfRef
- Phantom marker for “this entity’s own vehicle frame” — used by ECS adapters whose per-entity components carry frame phantoms but whose vehicle identity is determined at runtime by the entity itself.
- Structural
Frame - Structural (geometric-origin) frame of vehicle
V. Rotates with vehicle. - Sun
- Planet marker for Sun.
- TAI
- International Atomic Time.
- TDB
- Barycentric Dynamical Time (relativistic correction to TT).
- TT
- Terrestrial Time (TAI + 32.184 s).
- Time
Converter - Explicit converter between two time scales.
- UT1
- Universal Time 1 (Earth-rotation based).
- UTC
- Coordinated Universal Time (leap-second stepped).
Traits§
- Array3
Ext - Extension trait on
[f64; 3](raw component arrays from CSVs or JEOD initial conditions) producing frame-tagged 3-vectors. - F64Ext
- Unit-construction extension on
f64. - Frame
- Compile-time reference frame tag.
- Layout
- Compile-time quaternion storage layout marker.
- Planet
- Compile-time planet tag used to parameterize planet-fixed frames.
- Time
Scale - Compile-time time-scale tag.
- Transform
- Compile-time quaternion transformation convention marker.
- Vec3Ext
- Extension trait on
glam::DVec3producing frame-tagged 3-vectors. - Vehicle
- Compile-time vehicle tag used to parameterize vehicle-relative frames.
Type Aliases§
- Acceleration
- Acceleration in frame
F. Base SI unit: m/s². - Angular
Acceleration - Angular acceleration in frame
F. Base SI unit: rad/s². - Angular
Momentum - Angular momentum in frame
F. Base SI unit: kg·m²/s. - Angular
Velocity - Angular velocity in frame
F. Base SI unit: rad/s. - Force
- Force in frame
F. Base SI unit: newtons. - Jeod
Quat - The JEOD canonical quaternion type: scalar-first, left-transformation.
- Jerk
- Jerk (time derivative of acceleration) in frame
F. Base SI unit: m/s³. - Mass
Flow Rate - Scalar mass-flow rate.
- Position
- Position in frame
F(default:RootInertial). Base SI unit: meters. - Specific
AngMom - Scalar specific angular momentum.
- Specific
Energy - Scalar specific energy.
- Torque
- Torque in frame
F. Base SI unit: N·m. - Velocity
- Velocity in frame
F. Base SI unit: m/s.