diff options
Diffstat (limited to 'org/madore/ephem/Time.java')
-rw-r--r-- | org/madore/ephem/Time.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/org/madore/ephem/Time.java b/org/madore/ephem/Time.java new file mode 100644 index 0000000..3d2cb3e --- /dev/null +++ b/org/madore/ephem/Time.java @@ -0,0 +1,56 @@ +package org.madore.ephem; + +public final class Time { + + public static final class LeapSecond { + public int mjd; + public int offset; + public LeapSecond(int mjd, int offset) { + this.mjd = mjd; + this.offset = offset; + } + } + + public static final LeapSecond[] leapSecondsTable = new LeapSecond[] { + new LeapSecond(41317, 10), + new LeapSecond(41499, 11), + new LeapSecond(41683, 12), + new LeapSecond(42048, 13), + new LeapSecond(42413, 14), + new LeapSecond(42778, 15), + new LeapSecond(43144, 16), + new LeapSecond(43509, 17), + new LeapSecond(43874, 18), + new LeapSecond(44239, 19), + new LeapSecond(44786, 20), + new LeapSecond(45151, 21), + new LeapSecond(45516, 22), + new LeapSecond(46247, 23), + new LeapSecond(47161, 24), + new LeapSecond(47892, 25), + new LeapSecond(48257, 26), + new LeapSecond(48804, 27), + new LeapSecond(49169, 28), + new LeapSecond(49534, 29), + new LeapSecond(50083, 30), + new LeapSecond(50630, 31), + new LeapSecond(51179, 32), + new LeapSecond(53736, 33), + new LeapSecond(54832, 34), + new LeapSecond(56109, 35), + }; + + public static double utcToTt(int utcMjd, double utcSeconds) { + // Returns JD in TT + int i0 = 0; int i1 = leapSecondsTable.length; + while ( i1-i0 > 1 ) { + int i = (i0+i1)/2; + if ( utcMjd >= leapSecondsTable[i].mjd ) + i0 = i; + else + i1 = i; + } + return ( utcSeconds + leapSecondsTable[i0].offset + 32.184 )/86400. + utcMjd + 2400000.5; + } + +} |