pub struct DeltaT;Expand description
ΔT (Delta T) estimation functions.
Δ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
impl DeltaT
Sourcepub fn estimate(decimal_year: f64) -> Result<f64>
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 2024Sourcepub fn estimate_from_date_like<D: Datelike>(date: D) -> Result<f64>
Available on crate feature chrono only.
pub fn estimate_from_date_like<D: Datelike>(date: D) -> Result<f64>
chrono only.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
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);