FACT++  1.0
int eraDat ( int  iy,
int  im,
int  id,
double  fd,
double *  deltat 
)

Definition at line 3 of file dat.c.

References eraCal2jd(), and i.

Referenced by eraD2dtf(), eraDtf2d(), eraUt1utc(), eraUtctai(), eraUtcut1(), palDat(), and t_dat().

121 {
122 /* Release year for this version of eraDat */
123  enum { IYV = 2015};
124 
125 /* Reference dates (MJD) and drift rates (s/day), pre leap seconds */
126  static const double drift[][2] = {
127  { 37300.0, 0.0012960 },
128  { 37300.0, 0.0012960 },
129  { 37300.0, 0.0012960 },
130  { 37665.0, 0.0011232 },
131  { 37665.0, 0.0011232 },
132  { 38761.0, 0.0012960 },
133  { 38761.0, 0.0012960 },
134  { 38761.0, 0.0012960 },
135  { 38761.0, 0.0012960 },
136  { 38761.0, 0.0012960 },
137  { 38761.0, 0.0012960 },
138  { 38761.0, 0.0012960 },
139  { 39126.0, 0.0025920 },
140  { 39126.0, 0.0025920 }
141  };
142 
143 /* Number of Delta(AT) expressions before leap seconds were introduced */
144  enum { NERA1 = (int) (sizeof drift / sizeof (double) / 2) };
145 
146 /* Dates and Delta(AT)s */
147  static const struct {
148  int iyear, month;
149  double delat;
150  } changes[] = {
151  { 1960, 1, 1.4178180 },
152  { 1961, 1, 1.4228180 },
153  { 1961, 8, 1.3728180 },
154  { 1962, 1, 1.8458580 },
155  { 1963, 11, 1.9458580 },
156  { 1964, 1, 3.2401300 },
157  { 1964, 4, 3.3401300 },
158  { 1964, 9, 3.4401300 },
159  { 1965, 1, 3.5401300 },
160  { 1965, 3, 3.6401300 },
161  { 1965, 7, 3.7401300 },
162  { 1965, 9, 3.8401300 },
163  { 1966, 1, 4.3131700 },
164  { 1968, 2, 4.2131700 },
165  { 1972, 1, 10.0 },
166  { 1972, 7, 11.0 },
167  { 1973, 1, 12.0 },
168  { 1974, 1, 13.0 },
169  { 1975, 1, 14.0 },
170  { 1976, 1, 15.0 },
171  { 1977, 1, 16.0 },
172  { 1978, 1, 17.0 },
173  { 1979, 1, 18.0 },
174  { 1980, 1, 19.0 },
175  { 1981, 7, 20.0 },
176  { 1982, 7, 21.0 },
177  { 1983, 7, 22.0 },
178  { 1985, 7, 23.0 },
179  { 1988, 1, 24.0 },
180  { 1990, 1, 25.0 },
181  { 1991, 1, 26.0 },
182  { 1992, 7, 27.0 },
183  { 1993, 7, 28.0 },
184  { 1994, 7, 29.0 },
185  { 1996, 1, 30.0 },
186  { 1997, 7, 31.0 },
187  { 1999, 1, 32.0 },
188  { 2006, 1, 33.0 },
189  { 2009, 1, 34.0 },
190  { 2012, 7, 35.0 },
191  { 2015, 7, 36.0 }
192  };
193 
194 /* Number of Delta(AT) changes */
195  enum { NDAT = (int) (sizeof changes / sizeof changes[0]) };
196 
197 /* Miscellaneous local variables */
198  int j, i, m;
199  double da, djm0, djm;
200 
201 
202 /* Initialize the result to zero. */
203  *deltat = da = 0.0;
204 
205 /* If invalid fraction of a day, set error status and give up. */
206  if (fd < 0.0 || fd > 1.0) return -4;
207 
208 /* Convert the date into an MJD. */
209  j = eraCal2jd(iy, im, id, &djm0, &djm);
210 
211 /* If invalid year, month, or day, give up. */
212  if (j < 0) return j;
213 
214 /* If pre-UTC year, set warning status and give up. */
215  if (iy < changes[0].iyear) return 1;
216 
217 /* If suspiciously late year, set warning status but proceed. */
218  if (iy > IYV + 5) j = 1;
219 
220 /* Combine year and month to form a date-ordered integer... */
221  m = 12*iy + im;
222 
223 /* ...and use it to find the preceding table entry. */
224  for (i = NDAT-1; i >=0; i--) {
225  if (m >= (12 * changes[i].iyear + changes[i].month)) break;
226  }
227 
228 /* Prevent underflow warnings. */
229  if (i < 0) return -5;
230 
231 /* Get the Delta(AT). */
232  da = changes[i].delat;
233 
234 /* If pre-1972, adjust for drift. */
235  if (i < NERA1) da += (djm + fd - drift[i][0]) * drift[i][1];
236 
237 /* Return the Delta(AT) value. */
238  *deltat = da;
239 
240 /* Return the status. */
241  return j;
242 
243 }
int i
Definition: db_dim_client.c:21
int eraCal2jd(int iy, int im, int id, double *djm0, double *djm)
Definition: cal2jd.c:3

+ Here is the call graph for this function:

+ Here is the caller graph for this function: