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>
impl Time<UTC>
Sourcepub fn try_from_chrono_with(
dt: DateTime<Utc>,
ctx: &TimeContext,
) -> Result<Self, ConversionError>
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.
Sourcepub fn try_from_chrono(dt: DateTime<Utc>) -> Result<Self, ConversionError>
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.
Sourcepub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Self
pub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Self
Convenience panicking wrapper over
try_from_chrono_with.
Sourcepub fn from_chrono(dt: DateTime<Utc>) -> Self
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.
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: Scale> Time<S>
impl<S: Scale> Time<S>
Sourcepub fn raw_seconds_pair(self) -> (Second, Second)
pub fn raw_seconds_pair(self) -> (Second, Second)
Raw internal storage pair in J2000-TT seconds on the instance scale.
Source§impl<S: CoordinateScale> Time<S>
impl<S: CoordinateScale> Time<S>
Sourcepub fn try_from_raw_j2000_seconds_split(
hi: Second,
lo: Second,
) -> Result<Self, ConversionError>
pub fn try_from_raw_j2000_seconds_split( hi: Second, lo: Second, ) -> Result<Self, ConversionError>
Build from a split J2000-second pair on the scale’s coordinate axis.
This is the public constructor for FFI and wrapper layers that need to
preserve the compensated (hi, lo) representation instead of
flattening it to one scalar.
Source§impl<S: Scale> Time<S>
impl<S: Scale> Time<S>
Sourcepub fn to<T>(self) -> T::Outputwhere
T: InfallibleConversionTarget<S>,
pub fn to<T>(self) -> T::Outputwhere
T: InfallibleConversionTarget<S>,
Unified infallible conversion to a scale/view target.
Sourcepub fn try_to<T>(self) -> Result<T::Output, ConversionError>where
T: ConversionTarget<S>,
pub fn try_to<T>(self) -> Result<T::Output, ConversionError>where
T: ConversionTarget<S>,
Unified fallible conversion to a scale/view target.
Sourcepub fn to_with<T>(self, ctx: &TimeContext) -> Result<T::Output, ConversionError>where
T: ContextConversionTarget<S>,
pub fn to_with<T>(self, ctx: &TimeContext) -> Result<T::Output, ConversionError>where
T: ContextConversionTarget<S>,
Unified context-backed conversion to a scale/view target.
Sourcepub fn to_scale<S2: Scale>(self) -> Time<S2>where
S: InfallibleScaleConvert<S2>,
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.
Sourcepub fn to_scale_with<S2: Scale>(
self,
ctx: &TimeContext,
) -> Result<Time<S2>, ConversionError>where
S: ContextScaleConvert<S2>,
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> AddAssign<Quantity<Second>> for Time<S>
impl<S: CoordinateScale> AddAssign<Quantity<Second>> for Time<S>
Source§fn add_assign(&mut self, rhs: Second)
fn add_assign(&mut self, rhs: Second)
+= operation. Read moreSource§impl<S: Scale, F> From<EncodedTime<S, F>> for Time<S>where
F: InfallibleFormatForScale<S>,
impl<S: Scale, F> From<EncodedTime<S, F>> for Time<S>where
F: InfallibleFormatForScale<S>,
Source§fn from(value: EncodedTime<S, F>) -> Self
fn from(value: EncodedTime<S, F>) -> Self
Source§impl<S: Scale, F> From<Time<S>> for EncodedTime<S, F>where
F: InfallibleFormatForScale<S>,
impl<S: Scale, F> From<Time<S>> for EncodedTime<S, F>where
F: InfallibleFormatForScale<S>,
Source§impl<S: Scale> PartialOrd for Time<S>
impl<S: Scale> PartialOrd for Time<S>
Source§impl<S: CoordinateScale> Sub for Time<S>
impl<S: CoordinateScale> Sub for Time<S>
Source§impl<S: CoordinateScale> SubAssign<Quantity<Second>> for Time<S>
impl<S: CoordinateScale> SubAssign<Quantity<Second>> for Time<S>
Source§fn sub_assign(&mut self, rhs: Second)
fn sub_assign(&mut self, rhs: Second)
-= operation. Read more