Skip to main content

Moment

Struct Moment 

Source
pub struct Moment {
Show 13 fields pub year: i32, pub month: u32, pub day: u32, pub hour: u32, pub minute: u32, pub tz: f64, pub jd_ut: f64, pub jde: f64, pub sun_longitude: f64, pub sidereal_time: f64, pub obliquity: f64, pub civil_day: i64, pub lunar: LunarDate,
}
Expand description

时刻的共享天文/历法上下文:对一个出生/问事时刻,把所有「时间→天文量」的公共子计算 (儒略日、力学时、太阳视黄经、民用日序、农历)一次性算出并缓存。

这是「树即记忆化计算 DAG」的共享层:多片叶子(八字、紫微、择日…)共用同一个 Moment, 避免各自重复昂贵的日月历法计算。各叶以 compute_at(&Moment) 复用它。

Fields§

§year: i32

公历年。

§month: u32

公历月 1..12。

§day: u32

公历日 1..31。

§hour: u32

时 0..23。

§minute: u32

分 0..59。

§tz: f64

时区偏移小时。

§jd_ut: f64

世界时儒略日。

§jde: f64

力学时儒略日(含 ΔT)。

§sun_longitude: f64

太阳视黄经(度)。

§sidereal_time: f64

格林尼治平恒星时(度)——B 族算上升点/中天的共享量。

§obliquity: f64

黄道平交角 ε₀(度)——B 族算上升点/中天的共享量。

§civil_day: i64

民用日序(JDN)。

§lunar: LunarDate

农历日期。

Implementations§

Source§

impl Moment

Source

pub fn new( year: i32, month: u32, day: u32, hour: u32, minute: u32, tz: f64, ) -> Moment

由本地民用时刻构造,一次性算出全部共享天文/历法量。

Trait Implementations§

Source§

impl Clone for Moment

Source§

fn clone(&self) -> Moment

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 Copy for Moment

Source§

impl Debug for Moment

Source§

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

Formats the value using the given formatter. 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> 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 = !

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.