deep-time 0.1.0-alpha.2

High-precision time types, time scale conversions, relativistic time, and a flexible date and duration parser
Documentation
use crate::{ATTOS_PER_WEEK, Real, Dt, TSpan};

impl Dt {
    /// Creates a `Dt` in GPS Time (GPS) from a GPS week number and
    /// Time of Week (TOW).
    ///
    /// This is the exact inverse of [`Self::to_gps_week_and_tow`].
    ///
    /// - `week`: Full GPS week number (can be negative for dates before 1980).
    /// - `tow`: Time of Week as a [`TSpan`]. Values ≥ 604800 seconds are
    ///   automatically carried into the week number.
    ///
    /// The resulting `Dt` is always in `Scale::GPS`.
    #[inline]
    pub const fn from_gps_wk_and_tow(wk: i64, tow: TSpan) -> Self {
        let total_attos = (wk as i128) * ATTOS_PER_WEEK + tow.to_attos();
        Self::GPS_EPOCH.add(TSpan::from_attos(total_attos))
    }

    /// Creates a `Dt` in GPS Time from a GPS week number and
    /// floating-point Time of Week.
    ///
    /// This is the floating-point counterpart to [`Self::from_gps_wk_and_tow`].
    #[inline]
    pub const fn from_gps_wk_and_tow_f(week: i64, tow: Real) -> Self {
        let tow_span = TSpan::from_sec_f(tow);
        Self::from_gps_wk_and_tow(week, tow_span)
    }
}