Skip to content

Commit

Permalink
Merge 6a0213d into 1894edf
Browse files Browse the repository at this point in the history
  • Loading branch information
prakharcode committed May 12, 2018
2 parents 1894edf + 6a0213d commit d3bc19d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,32 @@ end
32.184 + leapsec - ΔUT1
end

"""
tttdb(jd1, jd2, dtr)
Transform a two-part Julian date from `TT` to `TDB`.
# Example
```jldoctest
julia> tt = Epoch{TT}(2.4578265e6, 0.30440190993249416)
2017-03-14T07:18:20.325 TT
julia> AstroTime.Epochs.tttdb(tt.jd1, tt.jd2, AstroTime.Epochs.deltatr(tdb))
(2.4578265e6, 0.30440190993249416)
```
"""
@inline function tttdb(jd1, jd2, dtr)
dtrd = dtr / SECONDS_PER_DAY
if jd1 > jd2
date = jd1
date1 = jd2 + dtrd
else
date = jd1 + dtrd
date1 = jd2
end
date, date1
end

# TAI <-> UTC
@transform UTC TAI ep begin
jd1, jd2 = julian1(ep), julian2(ep)
Expand Down Expand Up @@ -491,4 +517,3 @@ Epoch{T}(ep::Epoch{T}) where {T} = ep
end
ex
end

2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ AstroTime.update()
@test Epochs.dtdb(julian1(tdb), julian2(tdb), 0.0, 0.0, 0.0, 0.0) == ERFA.dtdb(julian1(tdb), julian2(tdb), 0.0, 0.0, 0.0, 0.0)
@test Epochs.tdbtt(julian1(tdb), julian2(tdb), Δtr(tdb)) == ERFA.tdbtt(julian1(tdb), julian2(tdb), Δtr(tdb))
@test Epochs.tdbtt(julian2(tdb), julian1(tdb), Δtr(tdb)) == ERFA.tdbtt(julian2(tdb), julian1(tdb), Δtr(tdb))
@test Epochs.tttdb(julian1(tt), julian2(tt), Δtr(tdb)) == ERFA.tttdb(julian1(tt), julian2(tt), Δtr(tdb))
@test Epochs.tttdb(julian2(tt), julian1(tt), Δtr(tdb)) == ERFA.tttdb(julian2(tt), julian1(tt), Δtr(tdb))
end
@testset "Leap Seconds" begin
@test leapseconds(TTEpoch(1959,1,1)) == 0
Expand Down

0 comments on commit d3bc19d

Please sign in to comment.