Skip to main content

Time

Struct Time 

Source
pub struct Time<S: Scale> { /* private fields */ }
Expand description

A point in time on scale S.

Internally, Time<S> stores a compensated (hi, lo) pair of seconds since J2000 TT on the scale’s coordinate axis. The pair sums to the exact value represented by the instance, while keeping the low-order remainder small enough to retain much better precision than a single f64.

Time<S> is intentionally modeled as an affine point, not as a raw scalar: subtracting two instants yields a duration, while adding or subtracting a duration shifts an instant. Internally this is represented with affn::SplitPoint1, which preserves the same point-vs-displacement semantics used elsewhere in the codebase.

The split representation exists because astronomical epochs are large values, while important corrections are often tiny. A single f64 would discard low-order precision too aggressively once epoch-sized values are combined with sub-second or microsecond-scale offsets, so Time<S> keeps the large component in hi and the residual correction in lo.

UTC remains special: it stores a continuous instant on the same internal axis used by TAI, but its civil interpretation still comes from the active UTC-TAI table. Raw JD/MJD/J2000-second helpers and second-based arithmetic operate on that stored instant axis; use the civil API when you need leap-second-labelled UTC values.

Implementations§

Source§

impl Time<UTC>

Source

pub fn try_from_chrono_with( dt: DateTime<Utc>, ctx: &TimeContext, ) -> Result<Self, ConversionError>

Build a UTC instant from a chrono::DateTime<Utc> using the context’s captured time-data bundle.

Source

pub fn try_from_chrono(dt: DateTime<Utc>) -> Result<Self, ConversionError>

Build a UTC instant from a chrono::DateTime<Utc>.

Snapshots the active time-data bundle at call time via TimeContext::new. For reproducible pipelines, prefer try_from_chrono_with with an explicit context.

Source

pub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Self

Convenience panicking wrapper over try_from_chrono_with.

Source

pub fn from_chrono(dt: DateTime<Utc>) -> Self

Convenience panicking wrapper over try_from_chrono.

Snapshots the active time-data bundle at call time via TimeContext::new. For reproducible pipelines, prefer from_chrono_with.

Source

pub fn try_to_chrono_with( self, ctx: &TimeContext, ) -> Result<DateTime<Utc>, ConversionError>

Convert to a chrono::DateTime<Utc>, preserving leap-second labels, using the context’s captured time-data bundle.

Source

pub fn try_to_chrono(self) -> Result<DateTime<Utc>, ConversionError>

Convert to a chrono::DateTime<Utc>, preserving leap-second labels.

Snapshots the active time-data bundle at call time via TimeContext::new. For reproducible pipelines, prefer try_to_chrono_with with an explicit context.

Source

pub fn to_chrono_with(self, ctx: &TimeContext) -> Option<DateTime<Utc>>

Convenience non-fallible wrapper (returns None on error) using the context’s captured time-data bundle.

Source

pub fn to_chrono(self) -> Option<DateTime<Utc>>

Convenience non-fallible wrapper (returns None on error).

Snapshots the active time-data bundle at call time via TimeContext::new. For reproducible pipelines, prefer to_chrono_with.

Source

pub fn is_leap_second_with(self, ctx: &TimeContext) -> bool

Returns true if this instant falls inside a positive leap second in UTC (e.g. 23:59:60) using the context’s captured time-data bundle.

Source

pub fn is_leap_second(self) -> bool

Returns true if this instant falls inside a positive leap second in UTC (e.g. 23:59:60).

Snapshots the active time-data bundle at call time via TimeContext::new. For reproducible pipelines, prefer is_leap_second_with.

Source§

impl<S: Scale> Time<S>

Source

pub fn raw_seconds_pair(self) -> (Second, Second)

Raw internal storage pair in J2000-TT seconds on the instance scale.

Source§

impl<S: Scale> Time<S>

Source

pub fn to<T>(self) -> T::Output

Unified infallible conversion to a scale/view target.

Source

pub fn try_to<T>(self) -> Result<T::Output, ConversionError>
where T: ConversionTarget<S>,

Unified fallible conversion to a scale/view target.

Source

pub fn to_with<T>(self, ctx: &TimeContext) -> Result<T::Output, ConversionError>

Unified context-backed conversion to a scale/view target.

Source

pub fn to_scale<S2: Scale>(self) -> Time<S2>
where S: InfallibleScaleConvert<S2>,

Infallible scale conversion. Compiles only for pairs with a closed-form, context-free conversion.

Source

pub fn to_scale_with<S2: Scale>( self, ctx: &TimeContext, ) -> Result<Time<S2>, ConversionError>
where S: ContextScaleConvert<S2>,

Context-required scale conversion (UT1 routes).

Trait Implementations§

Source§

impl<S: CoordinateScale> Add<Quantity<Second>> for Time<S>

Source§

type Output = Time<S>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Second) -> Self

Performs the + operation. Read more
Source§

impl<S: CoordinateScale> AddAssign<Quantity<Second>> for Time<S>

Source§

fn add_assign(&mut self, rhs: Second)

Performs the += operation. Read more
Source§

impl<S: Scale> Clone for Time<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Scale> Debug for Time<S>

Source§

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

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

impl<S: Scale> Display for Time<S>

Source§

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

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

impl<S: Scale, R> From<EncodedTime<S, R>> for Time<S>

Source§

fn from(value: EncodedTime<S, R>) -> Self

Converts to this type from the input type.
Source§

impl<S: Scale, R> From<Time<S>> for EncodedTime<S, R>

Source§

fn from(value: Time<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: Scale> PartialEq for Time<S>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Scale> PartialOrd for Time<S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: CoordinateScale> Sub<Quantity<Second>> for Time<S>

Source§

type Output = Time<S>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Second) -> Self

Performs the - operation. Read more
Source§

impl<S: CoordinateScale> Sub for Time<S>

Source§

type Output = Quantity<Second>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Second

Performs the - operation. Read more
Source§

impl<S: CoordinateScale> SubAssign<Quantity<Second>> for Time<S>

Source§

fn sub_assign(&mut self, rhs: Second)

Performs the -= operation. Read more
Source§

impl<S: Scale> Copy for Time<S>

Auto Trait Implementations§

§

impl<S> Freeze for Time<S>

§

impl<S> RefUnwindSafe for Time<S>

§

impl<S> Send for Time<S>

§

impl<S> Sync for Time<S>

§

impl<S> Unpin for Time<S>

§

impl<S> UnsafeUnpin for Time<S>

§

impl<S> UnwindSafe for Time<S>

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

Source§

impl<T, Right> ClosedAddAssign<Right> for T
where T: ClosedAdd<Right> + AddAssign<Right>,

Source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

Source§

impl<T, Right> ClosedSubAssign<Right> for T
where T: ClosedSub<Right> + SubAssign<Right>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,