pub struct Time<S: Scale, F: TimeFormat = J2000s> { /* private fields */ }Expand description
A point in time on scale S, tagged with external format phantom F.
The default F is J2000s, so Time<S> in code is Time<S, J2000s>:
SI seconds since J2000.0 TT on the scale’s coordinate axis.
Storage is always a compensated (hi, lo) pair of seconds. The format tag
does not duplicate storage; it only types the API (raw(), conversions, …).
§Preconditions
NaN must never appear in encoded scalars or storage components — behavior is undefined if it does.
±∞ may be carried when callers use instants as sentinels; operations that require finite coordinates
(ΔT loops, UTC civil decoding, POSIX Unix mapping, …) may still return ConversionError::NonFinite.
Implementations§
Source§impl<F> Time<TT, F>where
F: InfallibleFormatForScale<TT> + InfallibleConversionTarget<TT, Output = Time<TT, F>> + TimeFormat,
impl<F> Time<TT, F>where
F: InfallibleFormatForScale<TT> + InfallibleConversionTarget<TT, Output = Time<TT, F>> + TimeFormat,
Sourcepub fn try_from_chrono(dt: DateTime<Utc>) -> Result<Self, ConversionError>
pub fn try_from_chrono(dt: DateTime<Utc>) -> Result<Self, ConversionError>
Build a TT Time in format F from a UTC chrono timestamp.
Sourcepub fn from_chrono(dt: DateTime<Utc>) -> Self
pub fn from_chrono(dt: DateTime<Utc>) -> Self
Build a TT Time in format F from a UTC chrono timestamp.
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>
Like Self::try_from_chrono, but uses an explicit TimeContext.
Sourcepub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Self
pub fn from_chrono_with(dt: DateTime<Utc>, ctx: &TimeContext) -> Self
Like Self::from_chrono, but uses an explicit TimeContext.
Sourcepub fn try_to_chrono(self) -> Result<DateTime<Utc>, ConversionError>
pub fn try_to_chrono(self) -> Result<DateTime<Utc>, ConversionError>
Convert to a UTC chrono timestamp (TT → UTC using a default context).
Sourcepub fn to_chrono(self) -> Option<DateTime<Utc>>
pub fn to_chrono(self) -> Option<DateTime<Utc>>
Convert to a UTC chrono timestamp (TT → UTC using a default context).
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>
Like Self::try_to_chrono, but uses an explicit TimeContext.
Sourcepub fn to_chrono_with(self, ctx: &TimeContext) -> Option<DateTime<Utc>>
pub fn to_chrono_with(self, ctx: &TimeContext) -> Option<DateTime<Utc>>
Like Self::to_chrono, but uses an explicit TimeContext.
Source§impl<F: TimeFormat> Time<UTC, F>
impl<F: TimeFormat> Time<UTC, F>
Sourcepub fn try_from_chrono_with(
dt: DateTime<Utc>,
ctx: &TimeContext,
) -> Result<Time<UTC, J2000s>, ConversionError>
pub fn try_from_chrono_with( dt: DateTime<Utc>, ctx: &TimeContext, ) -> Result<Time<UTC, J2000s>, 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, J2000s>, ConversionError>
pub fn try_from_chrono( dt: DateTime<Utc>, ) -> Result<Time<UTC, J2000s>, 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, J2000s>
pub fn from_chrono_with( dt: DateTime<Utc>, ctx: &TimeContext, ) -> Time<UTC, J2000s>
Convenience panicking wrapper over
try_from_chrono_with.
Sourcepub fn from_chrono(dt: DateTime<Utc>) -> Time<UTC, J2000s>
pub fn from_chrono(dt: DateTime<Utc>) -> Time<UTC, J2000s>
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, F: TimeFormat> Time<S, F>
impl<S: Scale, F: TimeFormat> Time<S, F>
Sourcepub fn reinterpret<G: TimeFormat>(self) -> Time<S, G>
pub fn reinterpret<G: TimeFormat>(self) -> Time<S, G>
Same instant, different format tag (zero cost).
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, J2000s>
impl<S: CoordinateScale> Time<S, J2000s>
Sourcepub fn from_raw_j2000_seconds(seconds: Second) -> Result<Self, ConversionError>
pub fn from_raw_j2000_seconds(seconds: Second) -> Result<Self, ConversionError>
Build from J2000 TT seconds on the scale’s coordinate axis.
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.
Sourcepub fn shifted_by<U>(self, delta: Quantity<U>) -> Selfwhere
U: TimeUnit,
pub fn shifted_by<U>(self, delta: Quantity<U>) -> Selfwhere
U: TimeUnit,
Shift this instant forward by a typed duration.
Sourcepub fn shifted_back_by<U>(self, delta: Quantity<U>) -> Selfwhere
U: TimeUnit,
pub fn shifted_back_by<U>(self, delta: Quantity<U>) -> Selfwhere
U: TimeUnit,
Shift this instant backward by a typed duration.
Sourcepub fn duration_since(self, other: Self) -> Second
pub fn duration_since(self, other: Self) -> Second
Duration from other to self.
Sourcepub fn duration_until(self, other: Self) -> Second
pub fn duration_until(self, other: Self) -> Second
Duration from self to other.
Source§impl<S: CoordinateScale, F: InfallibleFormatForScale<S>> Time<S, F>
impl<S: CoordinateScale, F: InfallibleFormatForScale<S>> Time<S, F>
Source§impl<S: CoordinateScale, F> Time<S, F>where
F: FormatForScale<S>,
impl<S: CoordinateScale, F> Time<S, F>where
F: FormatForScale<S>,
pub fn try_raw_with( self, ctx: &TimeContext, ) -> Result<Quantity<F::Unit>, ConversionError>
Source§impl<S: Scale, F: TimeFormat> Time<S, F>
impl<S: Scale, F: TimeFormat> Time<S, F>
Sourcepub fn to<T>(self) -> T::Outputwhere
T: InfallibleConversionTarget<S, F>,
pub fn to<T>(self) -> T::Outputwhere
T: InfallibleConversionTarget<S, F>,
Unified infallible conversion to a scale/view target.
Sourcepub fn try_to<T>(self) -> Result<T::Output, ConversionError>where
T: ConversionTarget<S, F>,
pub fn try_to<T>(self) -> Result<T::Output, ConversionError>where
T: ConversionTarget<S, F>,
Unified fallible conversion to a scale/view target.
Sourcepub fn to_with<T>(self, ctx: &TimeContext) -> Result<T::Output, ConversionError>where
T: ContextConversionTarget<S, F>,
pub fn to_with<T>(self, ctx: &TimeContext) -> Result<T::Output, ConversionError>where
T: ContextConversionTarget<S, F>,
Unified context-backed conversion to a scale/view target.
Sourcepub fn to_scale<S2: Scale>(self) -> Time<S2, F>where
S: InfallibleScaleConvert<S2>,
pub fn to_scale<S2: Scale>(self) -> Time<S2, F>where
S: InfallibleScaleConvert<S2>,
Infallible scale conversion; preserves format tag F.
Sourcepub fn to_scale_with<S2: Scale>(
self,
ctx: &TimeContext,
) -> Result<Time<S2, F>, ConversionError>where
S: ContextScaleConvert<S2>,
pub fn to_scale_with<S2: Scale>(
self,
ctx: &TimeContext,
) -> Result<Time<S2, F>, ConversionError>where
S: ContextScaleConvert<S2>,
Context-required scale conversion (UT1 routes); preserves F.
Source§impl<S: Scale, F: FormatForScale<S>> Time<S, F>
impl<S: Scale, F: FormatForScale<S>> Time<S, F>
Sourcepub fn try_new(raw: Quantity<F::Unit>) -> Result<Self, ConversionError>
pub fn try_new(raw: Quantity<F::Unit>) -> Result<Self, ConversionError>
Fallible constructor from an encoded scalar.
Only surfaces domain failures from format decoding (UTC policy, leap seconds, ranges, …). Scalar hygiene is a caller precondition: NaN must not be passed; ±∞ is accepted only where the format decoder tolerates it.
Sourcepub fn try_new_with(
raw: Quantity<F::Unit>,
ctx: &TimeContext,
) -> Result<Self, ConversionError>
pub fn try_new_with( raw: Quantity<F::Unit>, ctx: &TimeContext, ) -> Result<Self, ConversionError>
Like Self::try_new, but uses ctx for UTC / POSIX decoding policy.
Source§impl<S: Scale, F: InfallibleFormatForScale<S>> Time<S, F>
impl<S: Scale, F: InfallibleFormatForScale<S>> Time<S, F>
Source§impl<S: CoordinateScale, F: InfallibleFormatForScale<S>> Time<S, F>
impl<S: CoordinateScale, F: InfallibleFormatForScale<S>> Time<S, F>
Source§impl Time<TT, JD>
TT Julian date at J2000.0 (JD 2 451 545.0); matches Self::jd_epoch_tt, usable in const.
impl Time<TT, JD>
TT Julian date at J2000.0 (JD 2 451 545.0); matches Self::jd_epoch_tt, usable in const.
pub const JD_EPOCH_J2000_0: Self
Source§impl<S: Scale> Time<S, JD>
impl<S: Scale> Time<S, JD>
Sourcepub fn jd_epoch_tt() -> Selfwhere
S: CoordinateScale,
pub fn jd_epoch_tt() -> Selfwhere
S: CoordinateScale,
TT J2000.0 as a Julian Date on scale S (JD 2 451 545.0).
pub fn value(self) -> f64where
S: CoordinateScale,
pub fn julian_centuries(self) -> f64where
S: CoordinateScale,
Trait Implementations§
Source§impl<S: CoordinateScale, F, U> Add<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
impl<S: CoordinateScale, F, U> Add<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
Source§impl<S: CoordinateScale, F, U> AddAssign<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
impl<S: CoordinateScale, F, U> AddAssign<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
Source§fn add_assign(&mut self, rhs: Quantity<U>)
fn add_assign(&mut self, rhs: Quantity<U>)
+= operation. Read moreSource§impl<S: CoordinateScale, F> Display for Time<S, F>
impl<S: CoordinateScale, F> Display for Time<S, F>
Source§impl<F> From<DateTime<Utc>> for Time<TT, F>where
F: InfallibleFormatForScale<TT> + InfallibleConversionTarget<TT, Output = Time<TT, F>> + TimeFormat,
impl<F> From<DateTime<Utc>> for Time<TT, F>where
F: InfallibleFormatForScale<TT> + InfallibleConversionTarget<TT, Output = Time<TT, F>> + TimeFormat,
Source§impl<S: Scale> From<Time<S, JD>> for Time<S>
impl<S: Scale> From<Time<S, JD>> for Time<S>
Source§fn from(value: JulianDate<S>) -> Self
fn from(value: JulianDate<S>) -> Self
Source§impl<S: Scale> From<Time<S, MJD>> for Time<S>
impl<S: Scale> From<Time<S, MJD>> for Time<S>
Source§fn from(value: ModifiedJulianDate<S>) -> Self
fn from(value: ModifiedJulianDate<S>) -> Self
Source§impl<S: CoordinateScale, F> LowerExp for Time<S, F>
impl<S: CoordinateScale, F> LowerExp for Time<S, F>
Source§impl<S: Scale, F: TimeFormat> PartialOrd for Time<S, F>
impl<S: Scale, F: TimeFormat> PartialOrd for Time<S, F>
Source§impl<S: CoordinateScale, F, U> Sub<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
impl<S: CoordinateScale, F, U> Sub<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
Source§impl<S: CoordinateScale, F> Sub for Time<S, F>
impl<S: CoordinateScale, F> Sub for Time<S, F>
Source§impl<S: CoordinateScale, F, U> SubAssign<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
impl<S: CoordinateScale, F, U> SubAssign<Quantity<U>> for Time<S, F>where
F: InfallibleFormatForScale<S>,
U: TimeUnit,
Source§fn sub_assign(&mut self, rhs: Quantity<U>)
fn sub_assign(&mut self, rhs: Quantity<U>)
-= operation. Read more