JulianDate

Struct JulianDate 

Source
pub struct JulianDate { /* private fields */ }
Expand description

Julian date representation for astronomical calculations.

Follows the SPA algorithm described in Reda & Andreas (2003). Supports both Julian Date (JD) and Julian Ephemeris Date (JDE) calculations.

Implementations§

Source§

impl JulianDate

Source

pub fn from_datetime<Tz: TimeZone>( datetime: &DateTime<Tz>, delta_t: f64, ) -> Result<Self>

Creates a new Julian date from a timezone-aware chrono DateTime.

This function properly handles timezone-aware datetimes by converting the entire datetime to UTC for accurate Julian Date calculations. Solar calculations require proper handling of the Earth’s rotation relative to the Sun, which is referenced to Universal Time.

§Arguments
  • datetime - Timezone-aware date and time
  • delta_t - ΔT in seconds (difference between TT and UT1)
§Returns

Julian date or error if the date is invalid

§Errors

Returns error if the date/time components are invalid (e.g., invalid month, day, hour).

Source

pub fn from_utc( year: i32, month: u32, day: u32, hour: u32, minute: u32, second: f64, delta_t: f64, ) -> Result<Self>

Creates a new Julian date from year, month, day, hour, minute, and second in UTC.

§Arguments
  • year - Year (can be negative for BCE years)
  • month - Month (1-12)
  • day - Day of month (1-31)
  • hour - Hour (0-23)
  • minute - Minute (0-59)
  • second - Second (0-59, can include fractional seconds)
  • delta_t - ΔT in seconds (difference between TT and UT1)
§Returns

Julian date or error if the date is invalid

§Errors

Returns error if any date/time component is outside valid ranges (month 1-12, day 1-31, hour 0-23, minute 0-59, second 0-59.999).

§Example
let jd = JulianDate::from_utc(2023, 6, 21, 12, 0, 0.0, 69.0).unwrap();
assert!(jd.julian_date() > 2_460_000.0);
Source

pub fn from_utc_simple( year: i32, month: u32, day: u32, hour: u32, minute: u32, second: f64, ) -> Result<Self>

Creates a Julian date assuming ΔT = 0.

§Arguments
  • year, month, day, hour, minute, second - UTC date/time components
§Returns

Julian date with ΔT = 0

§Errors

Returns error if the date/time components are outside valid ranges.

Source

pub const fn julian_date(&self) -> f64

Gets the Julian Date (JD) value.

§Returns

Julian Date referenced to UT1

Source

pub const fn delta_t(&self) -> f64

Gets the ΔT value in seconds.

§Returns

ΔT (Delta T) in seconds

Source

pub fn julian_ephemeris_day(&self) -> f64

Calculates the Julian Ephemeris Day (JDE).

JDE = JD + ΔT/86400

§Returns

Julian Ephemeris Day

Source

pub fn julian_century(&self) -> f64

Calculates the Julian Century (JC) from J2000.0.

JC = (JD - 2451545.0) / 36525

§Returns

Julian centuries since J2000.0 epoch

Source

pub fn julian_ephemeris_century(&self) -> f64

Calculates the Julian Ephemeris Century (JCE) from J2000.0.

JCE = (JDE - 2451545.0) / 36525

§Returns

Julian ephemeris centuries since J2000.0 epoch

Source

pub fn julian_ephemeris_millennium(&self) -> f64

Calculates the Julian Ephemeris Millennium (JME) from J2000.0.

JME = JCE / 10

§Returns

Julian ephemeris millennia since J2000.0 epoch

Trait Implementations§

Source§

impl Clone for JulianDate

Source§

fn clone(&self) -> JulianDate

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for JulianDate

Source§

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

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

impl PartialEq for JulianDate

Source§

fn eq(&self, other: &JulianDate) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for JulianDate

Source§

impl StructuralPartialEq for JulianDate

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