1 /*
2 * - - - - - - - - - - -
3 * g a l _ u t c 2 t t
4 * - - - - - - - - - - -
5 *
6 * This routine is part of the General Astrodynamics Library
7 *
8 * Description:
9 *
10 * This routine converts a UTC jd date to a TT jd date.
11 *
12 * Status:
13 *
14 * support routine.
15 *
16 * Given:
17 *
18 * utc1 d UTC date part 1 ( see Note 1 )
19 * utc2 d UTC date part 2 ( see Note 1 )
20 *
21 * Returned:
22 *
23 * *tt1 d TT date part 1 ( see Note 1 )
24 * *tt2 d TT date part 2 ( see Note 1 )
25 * gal_utc2tt i Status ( see Note 2 )
26 * 1 = dubious year (Note 2)
27 * 0 = OK
28 * Notes:
29 *
30 * 1) The Julian Date is apportioned in any convenient way between
31 * the arguments utc1 and utc2. For example, JD=2450123.7 could
32 * be expressed in any of these ways, among others:
33 *
34 * utc1 utc2
35 *
36 * 2450123.7 0.0 (JD method)
37 * 2451545.0 -1421.3 (J2000 method)
38 * 2400000.5 50123.2 (MJD method)
39 * 2450123.5 0.2 (date & time method)
40 *
41 * 2) TAI began at 1960 January 1.0 (JD 2436934.5) and it is improper
42 * to call the routine with an earlier epoch. If this is attempted,
43 * zero is returned together with a warning status.
44 *
45 * Because leap seconds cannot, in principle, be predicted in
46 * advance, a reliable check for dates beyond the valid range is
47 * impossible. To guard against gross errors, a year five or more
48 * after the release year of the present routine is considered dubious.
49 * In this case a warning status is returned but the result is
50 * computed in the normal way.
51 *
52 * Called:
53 *
54 * gal_dat Calculate delta(AT) = TAI-UTC
55 * gal_utc2tai Convert UTC to TAI
56 * gal_tai2tt Convert TAI to TT
57 *
58 * This revision:
59 *
60 * 2008 April 13
61 *
62 * Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
63 *
64 *-----------------------------------------------------------------------
65 */
66
67 #include "gal_utc2tt.h"
68 #include "gal_utc2tai.h"
69 #include "gal_tai2tt.h"
70
71 int
gal_utc2tt(double utc1,double utc2,double * tt1,double * tt2)72 gal_utc2tt
73 (
74 double utc1,
75 double utc2,
76 double *tt1,
77 double *tt2
78 )
79
80 {
81
82 int j ;
83
84 double tai1, tai2 ;
85
86 /*
87 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88 */
89
90 j = gal_utc2tai ( utc1, utc2, &tai1, &tai2 ) ;
91
92 if ( j == 0 || j == 1 ) {
93 gal_tai2tt ( tai1, tai2, tt1, tt2 ) ;
94 }
95 else {
96 *tt1 = 0.0 ;
97 *tt2 = 0.0 ;
98 }
99
100 return j ;
101
102 /*
103 * Finished.
104 */
105
106 }
107
108 /*
109 * gal - General Astrodynamics Library
110 * Copyright (C) 2008 Paul C. L. Willmott
111 *
112 * This program is free software; you can redistribute it and/or modify
113 * it under the terms of the GNU General Public License as published by
114 * the Free Software Foundation; either version 2 of the License, or
115 * (at your option) any later version.
116 *
117 * This program is distributed in the hope that it will be useful,
118 * but WITHOUT ANY WARRANTY; without even the implied warranty of
119 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
120 * GNU General Public License for more details.
121 *
122 * You should have received a copy of the GNU General Public License along
123 * with this program; if not, write to the Free Software Foundation, Inc.,
124 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
125 *
126 * Contact:
127 *
128 * Paul Willmott
129 * vp9mu@amsat.org
130 */
131