/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/ts/ut1tai.rs
Line | Count | Source |
1 | | use crate::consts::DAYSEC; |
2 | | |
3 | | /// Time scale transformation: Universal Time, UT1, to International |
4 | | /// Atomic Time, TAI. |
5 | | /// |
6 | | /// This function is part of the International Astronomical Union's |
7 | | /// SOFA (Standards of Fundamental Astronomy) software collection. |
8 | | /// |
9 | | /// Status: canonical. |
10 | | /// |
11 | | /// Given: |
12 | | /// ut11,ut12 double UT1 as a 2-part Julian Date |
13 | | /// dta double UT1-TAI in seconds |
14 | | /// |
15 | | /// Returned: |
16 | | /// tai1,tai2 double TAI as a 2-part Julian Date |
17 | | /// |
18 | | /// Returned (function value): |
19 | | /// int status: 0 = OK |
20 | | /// |
21 | 0 | pub fn ut1tai(ut11: f64, ut12: f64, dta: f64) -> Result<(f64, f64), i32> { |
22 | 0 | let dtad = dta / DAYSEC; |
23 | | let (tai1, tai2); |
24 | | |
25 | | /* Result, safeguarding precision. */ |
26 | 0 | if ut11.abs() > ut12.abs() { |
27 | 0 | tai1 = ut11; |
28 | 0 | tai2 = ut12 - dtad; |
29 | 0 | } else { |
30 | 0 | tai1 = ut11 - dtad; |
31 | 0 | tai2 = ut12; |
32 | 0 | } |
33 | | |
34 | 0 | Ok((tai1, tai2)) |
35 | 0 | } |