pub struct Time<S>where
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>
impl Time<UTC>
Sourcepub fn try_from_chrono_with(
dt: DateTime<Utc>,
ctx: &TimeContext,
) -> Result<Time<UTC>, ConversionError>
pub fn try_from_chrono_with( dt: DateTime<Utc>, ctx: &TimeContext, ) -> Result<Time<UTC>, ConversionError>
Build a UTC instant from a chrono::DateTime<Utc> using the context’s
captured time-data bundle.
Sourcepub fn try_from_chrono(dt: DateTime<Utc>) -> Result<Time<UTC>, ConversionError>
pub fn try_from_chrono(dt: DateTime<Utc>) -> Result<Time<UTC>, 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.
Sourcepub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Time<UTC>
pub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Time<UTC>
Convenience panicking wrapper over
try_from_chrono_with.
Sourcepub fn from_chrono(dt: DateTime<Utc>) -> Time<UTC>
pub fn from_chrono(dt: DateTime<Utc>) -> Time<UTC>
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.
Sourcepub fn try_to_chrono_with(
self,
ctx: &TimeContext,
) -> Result<DateTime<Utc>, ConversionError>
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.
Sourcepub fn try_to_chrono(self) -> Result<DateTime<Utc>, ConversionError>
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.
Sourcepub fn to_chrono_with(self, ctx: &TimeContext) -> Option<DateTime<Utc>>
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.
Sourcepub fn to_chrono(self) -> Option<DateTime<Utc>>
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.
Sourcepub fn is_leap_second_with(self, ctx: &TimeContext) -> bool
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.
Sourcepub fn is_leap_second(self) -> bool
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> Time<S>where
S: Scale,
impl<S> Time<S>where
S: Scale,
Sourcepub fn to<T>(self) -> <T as ConversionTarget<S>>::Outputwhere
T: InfallibleConversionTarget<S>,
pub fn to<T>(self) -> <T as ConversionTarget<S>>::Outputwhere
T: InfallibleConversionTarget<S>,
Unified infallible conversion to a scale/view target.
Sourcepub fn try_to<T>(
self,
) -> Result<<T as ConversionTarget<S>>::Output, ConversionError>where
T: ConversionTarget<S>,
pub fn try_to<T>(
self,
) -> Result<<T as ConversionTarget<S>>::Output, ConversionError>where
T: ConversionTarget<S>,
Unified fallible conversion to a scale/view target.
Sourcepub fn to_with<T>(
self,
ctx: &TimeContext,
) -> Result<<T as ContextConversionTarget<S>>::Output, ConversionError>where
T: ContextConversionTarget<S>,
pub fn to_with<T>(
self,
ctx: &TimeContext,
) -> Result<<T as ContextConversionTarget<S>>::Output, ConversionError>where
T: ContextConversionTarget<S>,
Unified context-backed conversion to a scale/view target.
Sourcepub fn to_scale<S2>(self) -> Time<S2>where
S2: Scale,
S: InfallibleScaleConvert<S2>,
pub fn to_scale<S2>(self) -> Time<S2>where
S2: Scale,
S: InfallibleScaleConvert<S2>,
Infallible scale conversion. Compiles only for pairs with a closed-form, context-free conversion.
Sourcepub fn to_scale_with<S2>(
self,
ctx: &TimeContext,
) -> Result<Time<S2>, ConversionError>where
S2: Scale,
S: ContextScaleConvert<S2>,
pub fn to_scale_with<S2>(
self,
ctx: &TimeContext,
) -> Result<Time<S2>, ConversionError>where
S2: Scale,
S: ContextScaleConvert<S2>,
Context-required scale conversion (UT1 routes).
Trait Implementations§
Source§impl<S, R> From<EncodedTime<S, R>> for Time<S>where
S: Scale,
R: InfallibleRepresentationForScale<S>,
impl<S, R> From<EncodedTime<S, R>> for Time<S>where
S: Scale,
R: InfallibleRepresentationForScale<S>,
Source§fn from(value: EncodedTime<S, R>) -> Time<S>
fn from(value: EncodedTime<S, R>) -> Time<S>
Source§impl<S, R> From<Time<S>> for EncodedTime<S, R>where
S: Scale,
R: InfallibleRepresentationForScale<S>,
impl<S, R> From<Time<S>> for EncodedTime<S, R>where
S: Scale,
R: InfallibleRepresentationForScale<S>,
Source§fn from(value: Time<S>) -> EncodedTime<S, R>
fn from(value: Time<S>) -> EncodedTime<S, R>
Source§impl<S> PartialOrd for Time<S>where
S: Scale,
impl<S> PartialOrd for Time<S>where
S: Scale,
Source§impl<S> Sub for Time<S>where
S: CoordinateScale,
impl<S> Sub for Time<S>where
S: CoordinateScale,
Source§impl TimeInstant for Time<TT>
impl TimeInstant for Time<TT>
impl<S> Copy for Time<S>where
S: Scale,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.