Skip to content

Epoch

Defined in: epoch.rs:273

pub struct Epoch\<S: [TimeScale](../../traits/timescale/) = [Utc](../utc/)\>

An astronomical epoch represented as Julian Date in scale S.

S defaults to Utc so that Epoch (without type parameter) means Epoch<Utc> — the most common user-facing scale.

内部表現は単一の jd: f64 だが、その値は scale S で解釈される JD である。 つまり Epoch<Utc>::from_jd(x).jd() == x (UTC JD として round-trip)、 Epoch<Tdb>::from_jd_tdb(x).jd() == x (TDB JD として round-trip) となる。

Scale 間の変換 (to_tdb(), to_tt() 等) は内部で TAI を経由し leap second や Fairhead 補正を適用して別 scale の JD を計算する。

fn jd(&self) -> f64

Return the Julian Date value, interpreted in scale S.


fn mjd(&self) -> f64

Return the Modified Julian Date value, interpreted in scale S.


fn scale_name() -> &‘static str

The human-readable scale name (e.g. “UTC”, “TDB”).


fn from_jd(jd: f64) -> Self

Create a UTC epoch from a raw Julian Date (treated as UTC JD).

Legacy API matching the pre-refactor Epoch::from_jd. The resulting Epoch<Utc>::jd() returns jd unchanged (round-trip identity).


fn from_mjd(mjd: f64) -> Self

Create a UTC epoch from a Modified Julian Date value.


fn j2000() -> Self

The J2000.0 reference epoch (JD 2451545.0).

歴史的には J2000.0 = 2000-01-01 12:00:00 TT だが、本実装では UTC scale で JD 2451545.0 を返す (後方互換のため)。厳密な TT J2000 を得るには Epoch::<Tt>::from_jd_tt を使う。


fn from_datetime(dt: &DateTime) -> Self

Create a UTC epoch from a DateTime value.


fn from_gregorian(year: i32, month: u32, day: u32, hour: u32, min: u32, sec: f64) -> Self

Create a UTC epoch from Gregorian calendar date and time.

Uses the standard Julian Date algorithm valid for dates after the Gregorian calendar reform (1582-10-15).


fn from_iso8601(s: &str) -> Option<Self>

Parse a UTC epoch from ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

Only UTC (Z suffix) is supported. Returns None if parsing fails.


fn now() -> Self

Create a UTC epoch from the current system time.


fn from_tle_epoch(year_2digit: u32, day_of_year: f64) -> Self

Create a UTC epoch from a TLE epoch (2-digit year + fractional day of year).

2-digit year convention (NORAD): 57-99 → 1957-1999, 00-56 → 2000-2056.


fn centuries_since_j2000(&self) -> f64

Julian centuries since J2000.0, computed directly from the UTC JD.

Note: This treats the UTC JD as if it were a dynamical-time JD, which is strictly incorrect for high-precision ephemeris calculations. For Meeus/JPL DE usage, prefer epoch.to_tdb().centuries_since_j2000(). This method is kept for legacy bit-level compatibility where UTC centuries were used interchangeably with dynamical-time centuries.


fn add_seconds(&self, dt: f64) -> Self

Advance the epoch by dt seconds using naive JD arithmetic (jd + dt/86400). Does NOT handle leap second boundaries.

Legacy API for bit-level compatibility with pre-refactor Epoch::add_seconds. For leap-second-aware arithmetic use add_si_seconds(Self::add_si_seconds) instead.


fn add_si_seconds(&self, dt: f64) -> Self

Advance the epoch by dt SI seconds, handling leap second boundaries.

Internally converts UTC → TAI, adds dt TAI seconds, and converts back to UTC. Crossing a leap second boundary correctly absorbs the extra second: 5 SI seconds from 2016-12-31T23:59:58 lands at 2017-01-01T00:00:02 (not 00:00:03), because one SI second is “consumed” by the 2017-01-01 leap.


fn to_datetime(&self) -> DateTime

Convert to Gregorian calendar date and time (UTC).


fn to_datetime_normalized(&self) -> DateTime

Convert to Gregorian calendar date and time (UTC), with leap second instants normalized to 00:00:00 of the next day.

Alias for to_datetime(Self::to_datetime) in Phase 1A (leap-instant display 23:59:60 is not yet distinguished).


fn gmst(&self) -> f64

Greenwich “sidereal time” in radians. Legacy method.

Actually computes the Earth Rotation Angle (IAU 2000 B1.8 / SOFA iauEra00) assuming UT1 ≈ UTC (ignores dUT1). For the proper canonical form use Epoch::<Ut1>::era after an explicit UT1 conversion via a proper EOP provider.

Kept on Epoch<Utc> for bit-level compatibility with the pre-refactor Epoch::gmst method. Will be removed when downstream callers migrate to Epoch<Ut1>::era.


fn to_tai(&self) -> [Epoch<Tai>](/)

Convert to TAI by applying the current leap-second offset.


fn to_tt(&self) -> [Epoch<Tt>](/)

Convert to TT via UTC → TAI → TT.


fn to_tdb(&self) -> [Epoch<Tdb>](/)

Convert to TDB via UTC → TAI → TT → TDB (Fairhead-Bretagnon periodic).


fn to_ut1_naive(&self) -> [Epoch<Ut1>](/)

Convert to UT1 assuming UT1 ≈ UTC (naive, legacy behavior).

真の UT1 が必要な場合は Epoch::<Utc>::to_ut1 (Ut1Offset provider を 引数に取る) を使う。本 method は NullEop 相当の dUT1 = 0 仮定で、 current arika の gmst() 実装との bit-level 互換を保つため提供される。


fn to_ut1<P: Ut1Offset + ?Sized>(&self, eop: &P) -> [Epoch<Ut1>](/)

Convert to UT1 using the dUT1 = UT1 − UTC correction provided by an EOP provider.

JD_UT1 = JD_UTC + dUT1 / 86400

dUT1 is looked up at the current UTC MJD and is typically in the range ±0.9 s. This is the precise UT1 conversion — the NullEop placeholder type does not implement Ut1Offset, so passing it is a compile error (see arika/tests/trybuild/).

The ?Sized bound lets callers pass trait objects directly (e.g. &dyn Ut1Offset or Box<dyn Ut1Offset>::as_ref()) alongside concrete types.

For a naive dUT1 = 0 conversion used by the legacy simple rotation path, use Epoch::<Utc>::to_ut1_naive instead.


fn from_jd_tai(jd: f64) -> Self

Create a TAI epoch from a Julian Date value interpreted as TAI JD.


fn to_tt(&self) -> [Epoch<Tt>](/)

Convert to TT by adding the constant 32.184 s offset.


fn to_utc(&self) -> [Epoch<Utc>](/)

Convert to UTC by subtracting the current leap-second offset.


fn from_jd_tt(jd: f64) -> Self

Create a TT epoch from a Julian Date value interpreted as TT JD.


fn centuries_since_j2000(&self) -> f64

Return TT Julian centuries since J2000.0.

この値が IAU 2006 precession / IAU 2000A/B nutation の独立変数。


fn to_tai(&self) -> [Epoch<Tai>](/)

Convert to TAI by subtracting the constant 32.184 s offset.


fn to_tdb(&self) -> [Epoch<Tdb>](/)

Convert to TDB via the Fairhead-Bretagnon periodic correction.


fn from_jd_tdb(jd: f64) -> Self

Create a TDB epoch from a Julian Date value interpreted as TDB JD.

JPL DE ephemerides use Teph which is for practical purposes indistinguishable from TDB (IAU 2006 Resolution B3).


fn centuries_since_j2000(&self) -> f64

Return TDB Julian centuries since J2000.0.

Meeus / JPL DE ephemeris と IAU 2009 WGCCRE body rotation の独立変数。


fn to_tt(&self) -> [Epoch<Tt>](/)

Convert to TT by applying the inverse Fairhead-Bretagnon correction.


fn from_jd_ut1(jd: f64) -> Self

Create a UT1 epoch from a Julian Date value interpreted as UT1 JD.


fn era(&self) -> f64

Earth Rotation Angle (ERA) in radians.

IAU 2000 Resolution B1.8 / SOFA iauEra00: ERA(T_u) = 2π × (0.7790572732640 + 1.00273781191135448 × T_u) where T_u = JD_UT1 − 2451545.0.

ERA は UT1 の definitional な関数であり、他の scale で計算することは 意味論的に間違い。したがって era() method は Epoch<Ut1> にのみ 提供される (Epoch<Tdb>::era() はコンパイルエラー)。