FACT++  1.0
int eraUtctai ( double  utc1,
double  utc2,
double *  tai1,
double *  tai2 
)

Definition at line 3 of file utctai.c.

References eraCal2jd(), eraDat(), eraJd2cal(), ERFA_DAYSEC, and id.

Referenced by eraApco13(), eraApio13(), eraTaiutc(), eraUtcut1(), and t_utctai().

64 {
65  int big1;
66  int iy, im, id, j, iyt, imt, idt;
67  double u1, u2, fd, dat0, dat12, w, dat24, dlod, dleap, z1, z2, a2;
68 
69 /* Put the two parts of the UTC into big-first order. */
70  big1 = ( utc1 >= utc2 );
71  if ( big1 ) {
72  u1 = utc1;
73  u2 = utc2;
74  } else {
75  u1 = utc2;
76  u2 = utc1;
77  }
78 
79 /* Get TAI-UTC at 0h today. */
80  j = eraJd2cal(u1, u2, &iy, &im, &id, &fd);
81  if ( j ) return j;
82  j = eraDat(iy, im, id, 0.0, &dat0);
83  if ( j < 0 ) return j;
84 
85 /* Get TAI-UTC at 12h today (to detect drift). */
86  j = eraDat(iy, im, id, 0.5, &dat12);
87  if ( j < 0 ) return j;
88 
89 /* Get TAI-UTC at 0h tomorrow (to detect jumps). */
90  j = eraJd2cal(u1+1.5, u2-fd, &iyt, &imt, &idt, &w);
91  if ( j ) return j;
92  j = eraDat(iyt, imt, idt, 0.0, &dat24);
93  if ( j < 0 ) return j;
94 
95 /* Separate TAI-UTC change into per-day (DLOD) and any jump (DLEAP). */
96  dlod = 2.0 * (dat12 - dat0);
97  dleap = dat24 - (dat0 + dlod);
98 
99 /* Remove any scaling applied to spread leap into preceding day. */
100  fd *= (ERFA_DAYSEC+dleap)/ERFA_DAYSEC;
101 
102 /* Scale from (pre-1972) UTC seconds to SI seconds. */
103  fd *= (ERFA_DAYSEC+dlod)/ERFA_DAYSEC;
104 
105 /* Today's calendar date to 2-part JD. */
106  if ( eraCal2jd(iy, im, id, &z1, &z2) ) return -1;
107 
108 /* Assemble the TAI result, preserving the UTC split and order. */
109  a2 = z1 - u1;
110  a2 += z2;
111  a2 += fd + dat0/ERFA_DAYSEC;
112  if ( big1 ) {
113  *tai1 = u1;
114  *tai2 = a2;
115  } else {
116  *tai1 = a2;
117  *tai2 = u1;
118  }
119 
120 /* Status. */
121  return j;
122 
123 }
char id[4]
Definition: FITS.h:71
#define ERFA_DAYSEC
Definition: erfam.h:75
int eraJd2cal(double dj1, double dj2, int *iy, int *im, int *id, double *fd)
Definition: jd2cal.c:3
int eraDat(int iy, int im, int id, double fd, double *deltat)
Definition: dat.c:3
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: