Skip to main content

Instant

Struct Instant 

Source
pub struct Instant {
    pub julian_day: JulianDay,
    pub scale: TimeScale,
}
Expand description

A Julian day tagged with a time scale.

Fields§

§julian_day: JulianDay

The numeric Julian day value.

§scale: TimeScale

The time scale used by the Julian day value.

Implementations§

Source§

impl Instant

Source

pub const fn new(julian_day: JulianDay, scale: TimeScale) -> Self

Creates a new instant from a Julian day and time scale.

Source

pub fn summary_line(&self) -> String

Returns a compact one-line rendering of the instant.

Source

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.

Source

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());
Source

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.

Source

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);
Source

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.

Source

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());
Source

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());
Source

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.

Source

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());
Source

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.

Source

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.

Source

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.

Source

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());
Source

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.

Source

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());
Source

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.

Source

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());

Trait Implementations§

Source§

impl Clone for Instant

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Instant

Source§

impl Debug for Instant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Instant

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Instant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Instant

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Instant

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Instant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.