1use crate::{ATTOS_PER_WEEK, Dt, Real, Scale};
2
3impl Dt {
4 #[inline]
15 pub const fn from_gps_wk_and_tow(wk: i64, tow: Dt) -> Self {
16 let total_attos = (wk as i128) * ATTOS_PER_WEEK + tow.to_attos();
17 Self::GPS_EPOCH.add(Dt::from_attos(total_attos, Scale::TAI))
18 }
19
20 #[inline]
25 pub const fn from_gps_wk_and_tow_f(week: i64, tow: Real) -> Self {
26 let tow_span = Dt::from_sec_f(tow);
27 Self::from_gps_wk_and_tow(week, tow_span)
28 }
29
30 pub const fn from_gps(elapsed: Dt) -> Self {
32 Self::GPS_EPOCH.add(elapsed)
33 }
34
35 #[inline]
37 pub const fn from_gps_f(elapsed_sec: Real) -> Self {
38 Self::from_gps(Dt::from_sec_f(elapsed_sec))
39 }
40
41 pub const fn from_cxcsec(elapsed: Dt) -> Self {
43 Self::CXC_EPOCH.add(elapsed)
44 }
45
46 #[inline]
48 pub const fn from_cxcsec_f(elapsed_sec: Real) -> Self {
49 Self::from_cxcsec(Dt::from_sec_f(elapsed_sec))
50 }
51
52 pub const fn from_galexsec(elapsed: Dt) -> Self {
54 let epoch_utc = Self::GPS_EPOCH.to(Scale::TAI, Scale::UTC);
55 epoch_utc.add(elapsed).to(Scale::UTC, Scale::TAI)
56 }
57
58 #[inline]
60 pub const fn from_galexsec_f(elapsed_sec: Real) -> Self {
61 Self::from_galexsec(Dt::from_sec_f(elapsed_sec))
62 }
63}