Skip to main content

TimeContext

Struct TimeContext 

Source
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 rangeDefault 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 overlappreferred highest-fidelity bundled UT1 path
EOP prediction range< 0.2 s from the bundled short-range daily prediction over the compiled prediction overlappreferred highest-fidelity bundled UT1 path
Beyond EOPmonthly ΔT only; prediction uncertainty growsfalls 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

Source

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.

Source

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.

Source

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();
Source

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.

Source

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

Source§

fn clone(&self) -> TimeContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeContext

Source§

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

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

impl Default for TimeContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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.