pub struct TimeContext { /* private fields */ }Expand description
Explicit, immutable context for conversions that need one.
A TimeContext snapshots the active time-data bundle at construction time
and selects which parts of that snapshot back context-required conversions.
The default constructor TimeContext::new uses the monthly ΔT series from
the captured bundle, matching the behaviour of previous versions;
TimeContext::with_builtin_eop selects the daily IERS finals2000A.all
series from that same snapshot for the highest-fidelity bundled UT1 path
inside its coverage window.
§ΔT / UT1 accuracy
| Epoch range | Default context (monthly ΔT) | with_builtin_eop() |
|---|---|---|
| Pre-948 CE | ±hundreds of s (Stephenson & Houlden quadratic) | same (outside EOP range) |
| 948–1619 | ±15 s (Stephenson & Houlden) | same |
| 1620–1973 | ±0.1–1 s (Meeus biennial table) | same |
| 1973 – EOP start | ~0.01 s (USNO monthly) | same |
| EOP observed range | < 15 ms from the bundled daily IERS-derived path over the compiled observed overlap | preferred highest-fidelity bundled UT1 path |
| EOP prediction range | < 0.2 s from the bundled short-range daily prediction over the compiled prediction overlap | preferred highest-fidelity bundled UT1 path |
| Beyond EOP | monthly ΔT only; prediction uncertainty grows | falls back to monthly ΔT |
The builtin EOP is only consulted inside the captured bundle’s coverage; outside of that range the monthly ΔT path applies unchanged. Construct a fresh context after refreshing the active bundle if you want to use the updated runtime data.
Implementations§
Source§impl TimeContext
impl TimeContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a default context backed by the monthly ΔT table.
This is the lightweight, always-available choice. It does not consult the daily EOP series even when the bundled data contains one.
Sourcepub fn with_builtin_eop() -> Self
pub fn with_builtin_eop() -> Self
Construct a context that prefers the compiled daily IERS
finals2000A.all series for UT1 conversions when the epoch is
within its coverage window.
Outside the bundled EOP coverage, this falls back to the same monthly
ΔT path used by TimeContext::new.
Sourcepub fn allow_pre_definition_utc(self) -> Self
pub fn allow_pre_definition_utc(self) -> Self
Allow UTC conversions for dates before 1961-01-01.
By default, Time::<UTC>::try_from_chrono_with and related conversions
return crate::ConversionError::UtcBeforeDefinition for any date
before MJD 37 300 (1961-01-01), because UTC was not an international
standard before that date and the back-extrapolated offset is
historically fabricated.
Calling this method on a context opts into the approximate continuation: the first official UTC-TAI segment is extrapolated backwards. Round-trips close, but the values are not standards-defined UTC.
§Example
use tempoch_core::{TimeContext, Time, UTC};
use chrono::DateTime;
let dt = DateTime::from_timestamp(-631_152_000, 0).unwrap();
let ctx = TimeContext::new().allow_pre_definition_utc();
let utc = Time::<UTC>::try_from_chrono_with(dt, &ctx).unwrap();Sourcepub fn eop_at(&self, mjd_utc: Day) -> Option<EopValues>
pub fn eop_at(&self, mjd_utc: Day) -> Option<EopValues>
Interpolated EOP at mjd_utc, if this context has an EOP source and
the MJD is in range.
This exposes the same interpolated values that context-backed scale conversions consult internally, so callers can inspect or reuse them without reimplementing the lookup path.
Sourcepub fn ut1_minus_utc(&self, mjd_utc: Day) -> Option<Second>
pub fn ut1_minus_utc(&self, mjd_utc: Day) -> Option<Second>
Interpolated UT1 - UTC from the context’s EOP source, if available.
Returns None when this context is monthly-ΔT-only or when the epoch is
outside the captured EOP coverage window.
Trait Implementations§
Source§impl Clone for TimeContext
impl Clone for TimeContext
Source§fn clone(&self) -> TimeContext
fn clone(&self) -> TimeContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimeContext
impl Debug for TimeContext
Auto Trait Implementations§
impl Freeze for TimeContext
impl RefUnwindSafe for TimeContext
impl Send for TimeContext
impl Sync for TimeContext
impl Unpin for TimeContext
impl UnsafeUnpin for TimeContext
impl UnwindSafe for TimeContext
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.