Coverage Report

Created: 2026-07-30 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/ts/tcgtt.rs
Line
Count
Source
1
use crate::consts::{DAYSEC, DJM0, DJM77, ELG, TTMTAI};
2
3
///  Time scale transformation:  Geocentric Coordinate Time, TCG, to
4
///  Terrestrial 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
///     tcg1,tcg2  double    TCG as a 2-part Julian Date
13
///
14
///  Returned:
15
///     tt1,tt2    double    TT as a 2-part Julian Date
16
///
17
///  Returned (function value):
18
///                int       status:  0 = OK
19
///
20
0
pub fn tcgtt(tcg1: f64, tcg2: f64) -> Result<(f64, f64), i32> {
21
    /* 1977 Jan 1 00:00:32.184 TT, as MJD */
22
0
    let t77t: f64 = DJM77 + TTMTAI / DAYSEC;
23
24
    let (tt1, tt2);
25
26
    /* Result, safeguarding precision. */
27
0
    if tcg1.abs() > tcg2.abs() {
28
0
        tt1 = tcg1;
29
0
        tt2 = tcg2 - ((tcg1 - DJM0) + (tcg2 - t77t)) * ELG;
30
0
    } else {
31
0
        tt1 = tcg1 - ((tcg2 - DJM0) + (tcg1 - t77t)) * ELG;
32
0
        tt2 = tcg2;
33
0
    }
34
35
0
    Ok((tt1, tt2))
36
0
}