pub struct Instant {
pub julian_day: JulianDay,
pub scale: TimeScale,
}Expand description
A Julian day tagged with a time scale.
Fields§
§julian_day: JulianDayThe numeric Julian day value.
scale: TimeScaleThe time scale used by the Julian day value.
Implementations§
Source§impl Instant
impl Instant
Sourcepub const fn new(julian_day: JulianDay, scale: TimeScale) -> Self
pub const fn new(julian_day: JulianDay, scale: TimeScale) -> Self
Creates a new instant from a Julian day and time scale.
Sourcepub fn summary_line(&self) -> String
pub fn summary_line(&self) -> String
Returns a compact one-line rendering of the instant.
Sourcepub fn with_time_scale_conversion(
self,
conversion: TimeScaleConversion,
) -> Result<Self, TimeScaleConversionError>
pub fn with_time_scale_conversion( self, conversion: TimeScaleConversion, ) -> Result<Self, TimeScaleConversionError>
Applies a caller-supplied time-scale conversion policy.
This helper is the generic counterpart to the source-specific
tt_from_* / tdb_from_* methods. It lets callers package the explicit
source, target, and offset choice into one typed record when they want
to keep the conversion contract alongside the instant.
Sourcepub fn validate_time_scale_conversion(
self,
conversion: TimeScaleConversion,
) -> Result<(), TimeScaleConversionError>
pub fn validate_time_scale_conversion( self, conversion: TimeScaleConversion, ) -> Result<(), TimeScaleConversionError>
Validates a caller-supplied time-scale conversion policy without retagging the instant.
This is the foundation-layer counterpart to
TimeScaleConversion::validate, which lets callers preflight the same
explicit source/target/offset contract directly from an instant when
they do not yet want to mutate it.
§Example
use pleiades_types::{Instant, JulianDay, TimeScale, TimeScaleConversion};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Ut1);
let policy = TimeScaleConversion::new(TimeScale::Ut1, TimeScale::Tt, 64.184);
assert!(instant.validate_time_scale_conversion(policy).is_ok());Sourcepub fn with_time_scale_offset(
self,
target_scale: TimeScale,
offset_seconds: f64,
) -> Self
pub fn with_time_scale_offset( self, target_scale: TimeScale, offset_seconds: f64, ) -> Self
Returns this instant with a caller-supplied offset applied and a new time scale tag.
The offset is expressed as target - source in SI seconds. For example,
callers converting UT1 to TT can pass Delta T (TT - UT1) and set
target_scale to TimeScale::Tt. This helper intentionally performs
no leap-second, DUT1, Delta T, or relativistic modeling; it only makes the
caller-provided policy explicit and reproducible. Callers should pass a
finite offset; the validated signed helpers reject non-finite values
before reaching this low-level retagging step.
Sourcepub fn with_time_scale_offset_checked(
self,
target_scale: TimeScale,
offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn with_time_scale_offset_checked( self, target_scale: TimeScale, offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Returns this instant with a caller-supplied offset applied and a new time scale tag after validating the source scale and offset.
This is the checked counterpart to Instant::with_time_scale_offset.
It keeps the same explicit target - source interpretation while
rejecting non-finite offsets and mismatched source scales before the
instant is retagged.
§Example
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Ut1);
let converted = instant
.with_time_scale_offset_checked(TimeScale::Tt, 64.184)
.expect("validated offset");
assert_eq!(converted.scale, TimeScale::Tt);Sourcepub fn mean_obliquity(self) -> Angle
pub fn mean_obliquity(self) -> Angle
Returns the mean obliquity of the ecliptic for this instant.
The value uses the shared cubic approximation currently used throughout
the workspace for precession-era obliquity values. The backends’
J2000 equatorial channel does not use it; it rotates by
OBLIQUITY_J2000_DEG instead. It is
expressed as a typed angle so callers can pass it directly into
coordinate conversion helpers.
Sourcepub fn tt_from_ut1(
self,
delta_t: Duration,
) -> Result<Self, TimeScaleConversionError>
pub fn tt_from_ut1( self, delta_t: Duration, ) -> Result<Self, TimeScaleConversionError>
Converts a UT1-tagged instant to TT using caller-supplied Delta T.
delta_t must be the value TT - UT1. Use this when validation data or
an application already has an explicit Delta T policy and wants to pass a
TT instant to backends that require TT. UTC-to-TT conversion is not
represented by this helper, because UTC also requires leap-second and
DUT1 handling outside the current type layer.
For signed TT - UT1 policies, use Instant::tt_from_ut1_signed.
§Example
use std::time::Duration;
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Ut1);
let converted = instant.tt_from_ut1(Duration::from_secs_f64(64.184)).expect("UT1-tagged instant");
assert_eq!(converted.scale, TimeScale::Tt);
assert!(converted.julian_day.days() > instant.julian_day.days());Sourcepub fn tt_from_ut1_signed(
self,
offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tt_from_ut1_signed( self, offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a UT1-tagged instant to TT using a caller-supplied signed offset.
offset_seconds must be the already-chosen signed TT - UT1 offset in
SI seconds. The helper intentionally does not model leap seconds or
DUT1 by itself; it only makes a caller-supplied UT1-to-TT policy explicit
and reproducible for applications that need a TT-tagged request surface.
§Example
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Ut1);
let converted = instant.tt_from_ut1_signed(64.184).expect("UT1-tagged instant");
assert_eq!(converted.scale, TimeScale::Tt);
assert!(converted.julian_day.days() > instant.julian_day.days());Sourcepub fn tt_from_utc(
self,
delta_t: Duration,
) -> Result<Self, TimeScaleConversionError>
pub fn tt_from_utc( self, delta_t: Duration, ) -> Result<Self, TimeScaleConversionError>
Converts a UTC-tagged instant to TT using caller-supplied offset.
delta_t must be the already-chosen TT - UTC offset in SI seconds.
The helper intentionally does not model leap seconds or DUT1 by itself;
it only makes a caller-supplied UTC-to-TT policy explicit and
reproducible for applications that start from civil time.
For signed TT - UTC policies, use Instant::tt_from_utc_signed.
Sourcepub fn tt_from_utc_signed(
self,
offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tt_from_utc_signed( self, offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a UTC-tagged instant to TT using a caller-supplied signed offset.
offset_seconds must be the already-chosen signed TT - UTC offset in
SI seconds. The helper intentionally does not model leap seconds or
DUT1 by itself; it only makes a caller-supplied UTC-to-TT policy explicit
and reproducible for applications that need a TT-tagged request surface.
§Example
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Utc);
let converted = instant.tt_from_utc_signed(64.184).expect("UTC-tagged instant");
assert_eq!(converted.scale, TimeScale::Tt);
assert!(converted.julian_day.days() > instant.julian_day.days());Sourcepub fn tdb_from_tt(
self,
offset: Duration,
) -> Result<Self, TimeScaleConversionError>
pub fn tdb_from_tt( self, offset: Duration, ) -> Result<Self, TimeScaleConversionError>
Converts a TT-tagged instant to TDB using a caller-supplied offset.
offset must be the already-chosen TDB - TT offset in SI seconds.
For signed TDB-TT policies, use Instant::tdb_from_tt_signed. The
helper intentionally does not model relativistic terms by itself; it
only makes a caller-supplied TT-to-TDB policy explicit and reproducible
for applications that need a TDB-tagged request surface.
Sourcepub fn tdb_from_tt_signed(
self,
offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tdb_from_tt_signed( self, offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a TT-tagged instant to TDB using a caller-supplied signed offset.
offset_seconds must be the already-chosen signed TDB - TT offset in
SI seconds. The helper intentionally does not model relativistic terms by
itself; it only makes a caller-supplied TT-to-TDB policy explicit and
reproducible for applications that need a TDB-tagged request surface.
Sourcepub fn tt_from_tdb(
self,
offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tt_from_tdb( self, offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a TDB-tagged instant to TT using a caller-supplied signed offset.
offset_seconds must be the already-chosen signed TT - TDB offset in
SI seconds. The helper intentionally does not model relativistic terms by
itself; it only makes a caller-supplied TDB-to-TT policy explicit and
reproducible for applications that need a TT-tagged request surface.
Sourcepub fn tt_from_tdb_signed(
self,
offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tt_from_tdb_signed( self, offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a TDB-tagged instant to TT using a caller-supplied signed offset.
This is an explicit alias for Instant::tt_from_tdb that mirrors the
signed helper naming used for the other time-scale conversion policies.
§Example
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Tdb);
let converted = instant.tt_from_tdb_signed(-0.001_657).expect("TDB-tagged instant");
assert_eq!(converted.scale, TimeScale::Tt);
assert!(converted.julian_day.days() < instant.julian_day.days());Sourcepub fn tdb_from_ut1(
self,
tt_offset: Duration,
tdb_offset: Duration,
) -> Result<Self, TimeScaleConversionError>
pub fn tdb_from_ut1( self, tt_offset: Duration, tdb_offset: Duration, ) -> Result<Self, TimeScaleConversionError>
Converts a UT1-tagged instant to TDB using caller-supplied TT-UT1 and TDB-TT offsets.
tt_offset must be the already-chosen TT - UT1 offset in SI
seconds. tdb_offset must be the already-chosen TDB - TT offset in
SI seconds. The helper intentionally does not model leap seconds,
DUT1, or relativistic terms by itself; it only composes caller-supplied
policy steps into a reproducible TDB-tagged instant.
Sourcepub fn tdb_from_ut1_signed(
self,
tt_offset: Duration,
tdb_offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tdb_from_ut1_signed( self, tt_offset: Duration, tdb_offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a UT1-tagged instant to TDB using caller-supplied TT-UT1 and signed TDB-TT offsets.
tt_offset must be the already-chosen TT - UT1 offset in SI
seconds. tdb_offset_seconds must be the already-chosen signed
TDB - TT offset in SI seconds. The helper intentionally does not
model leap seconds, DUT1, or relativistic terms by itself; it only
composes caller-supplied policy steps into a reproducible TDB-tagged
instant.
§Example
use std::time::Duration;
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Ut1);
let converted = instant
.tdb_from_ut1_signed(Duration::from_secs_f64(64.184), -0.001_657)
.expect("UT1-tagged instant");
assert_eq!(converted.scale, TimeScale::Tdb);
assert!(converted.julian_day.days() > instant.julian_day.days());Sourcepub fn tdb_from_utc(
self,
tt_offset: Duration,
tdb_offset: Duration,
) -> Result<Self, TimeScaleConversionError>
pub fn tdb_from_utc( self, tt_offset: Duration, tdb_offset: Duration, ) -> Result<Self, TimeScaleConversionError>
Converts a UTC-tagged instant to TDB using caller-supplied TT-UTC and TDB-TT offsets.
tt_offset must be the already-chosen TT - UTC offset in SI seconds.
tdb_offset must be the already-chosen TDB - TT offset in SI
seconds. The helper intentionally does not model leap seconds, DUT1, or
relativistic terms by itself; it only composes caller-supplied policy
steps into a reproducible TDB-tagged instant.
Sourcepub fn tdb_from_utc_signed(
self,
tt_offset: Duration,
tdb_offset_seconds: f64,
) -> Result<Self, TimeScaleConversionError>
pub fn tdb_from_utc_signed( self, tt_offset: Duration, tdb_offset_seconds: f64, ) -> Result<Self, TimeScaleConversionError>
Converts a UTC-tagged instant to TDB using caller-supplied TT-UTC and signed TDB-TT offsets.
tt_offset must be the already-chosen TT - UTC offset in SI seconds.
tdb_offset_seconds must be the already-chosen signed TDB - TT
offset in SI seconds. The helper intentionally does not model leap
seconds, DUT1, or relativistic terms by itself; it only composes
caller-supplied policy steps into a reproducible TDB-tagged instant.
§Example
use std::time::Duration;
use pleiades_types::{Instant, JulianDay, TimeScale};
let instant = Instant::new(JulianDay::from_days(2_451_545.0), TimeScale::Utc);
let converted = instant
.tdb_from_utc_signed(Duration::from_secs_f64(64.184), -0.001_657)
.expect("UTC-tagged instant");
assert_eq!(converted.scale, TimeScale::Tdb);
assert!(converted.julian_day.days() > instant.julian_day.days());