DeltaT

Struct DeltaT 

Source
pub struct DeltaT;
Expand description

Utilities for estimating ΔT (Delta T) values.

ΔT represents the difference between Terrestrial Time (TT) and Universal Time (UT1). These estimates are based on Espenak and Meeus polynomial fits updated in 2014.

Implementations§

Source§

impl DeltaT

Source

pub fn estimate(decimal_year: f64) -> Result<f64>

Estimates ΔT for a given decimal year.

Based on polynomial fits from Espenak & Meeus, updated 2014. See: https://www.eclipsewise.com/help/deltatpoly2014.html

§Arguments
  • decimal_year - Year with fractional part (e.g., 2024.5 for mid-2024)
§Returns

Estimated ΔT in seconds

§Errors

Returns error for years outside the valid range (-500 to 3000 CE)

§Example
let delta_t = DeltaT::estimate(2024.0).unwrap();
assert!(delta_t > 60.0 && delta_t < 80.0); // Reasonable range for 2024
Source

pub fn estimate_from_date(year: i32, month: u32) -> Result<f64>

Estimates ΔT from year and month.

Calculates decimal year as: year + (month - 0.5) / 12

§Arguments
  • year - Year
  • month - Month (1-12)
§Returns

Estimated ΔT in seconds

§Errors

Returns error if month is outside the range 1-12.

Source

pub fn estimate_from_date_like<D: Datelike>(date: D) -> Result<f64>

Estimates ΔT from any date-like type.

Convenience method that extracts the year and month from any chrono type that implements Datelike (DateTime, NaiveDateTime, NaiveDate, etc.).

§Arguments
  • date - Any date-like type
§Returns

Estimated ΔT in seconds

§Errors

Returns error if the date components are invalid.

§Example

// Works with DateTime
let datetime = "2024-06-21T12:00:00-07:00".parse::<DateTime<FixedOffset>>().unwrap();
let delta_t = DeltaT::estimate_from_date_like(datetime).unwrap();
assert!(delta_t > 60.0 && delta_t < 80.0);

// Also works with NaiveDate
let date = NaiveDate::from_ymd_opt(2024, 6, 21).unwrap();
let delta_t2 = DeltaT::estimate_from_date_like(date).unwrap();
assert_eq!(delta_t, delta_t2);

Auto Trait Implementations§

§

impl Freeze for DeltaT

§

impl RefUnwindSafe for DeltaT

§

impl Send for DeltaT

§

impl Sync for DeltaT

§

impl Unpin for DeltaT

§

impl UnwindSafe for DeltaT

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