/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/ts/ut1tt.rs
Line | Count | Source |
1 | | use crate::consts::DAYSEC; |
2 | | |
3 | | /// Time scale transformation: Universal Time, UT1, to Terrestrial |
4 | | /// Time, TT. |
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 | | /// ``` |
13 | | /// ut11,ut12 double UT1 as a 2-part Julian Date |
14 | | /// dt double TT-UT1 in seconds |
15 | | /// ``` |
16 | | /// Returned: |
17 | | /// ``` |
18 | | /// tt1,tt2 double TT as a 2-part Julian Date |
19 | | /// ``` |
20 | | /// Returned (function value): |
21 | | /// ``` |
22 | | /// int status: 0 = OK |
23 | | /// ``` |
24 | | /// Notes: |
25 | | /// |
26 | | /// 1) ut11+ut12 is Julian Date, apportioned in any convenient way |
27 | | /// between the two arguments, for example where ut11 is the Julian |
28 | | /// Day Number and ut12 is the fraction of a day. The returned |
29 | | /// tt1,tt2 follow suit. |
30 | | /// |
31 | | /// 2) The argument dt is classical Delta T. |
32 | | /// |
33 | | /// Reference: |
34 | | /// |
35 | | /// Explanatory Supplement to the Astronomical Almanac, |
36 | | /// P. Kenneth Seidelmann (ed), University Science Books (1992) |
37 | | /// |
38 | 0 | pub fn ut1tt(ut11: f64, ut12: f64, dt: f64) -> Result<(f64, f64), i32> { |
39 | 0 | let dtd = dt / DAYSEC; |
40 | | |
41 | | // Result, safeguarding precision. |
42 | 0 | let (tt1, tt2) = if ut11.abs() > ut12.abs() { |
43 | 0 | (ut11, ut12 + dtd) |
44 | | } else { |
45 | 0 | (ut11 + dtd, ut12) |
46 | | }; |
47 | | |
48 | | /* Status (always OK). */ |
49 | 0 | Ok((tt1, tt2)) |
50 | 0 | } |