FACT++  1.0
int eraDtf2d ( const char *  scale,
int  iy,
int  im,
int  id,
int  ihr,
int  imn,
double  sec,
double *  d1,
double *  d2 
)

Definition at line 4 of file dtf2d.c.

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

Referenced by t_dtf2d().

81 {
82  int js, iy2, im2, id2;
83  double dj, w, day, seclim, dat0, dat12, dat24, dleap, time;
84 
85 /* Today's Julian Day Number. */
86  js = eraCal2jd(iy, im, id, &dj, &w);
87  if ( js ) return js;
88  dj += w;
89 
90 /* Day length and final minute length in seconds (provisional). */
91  day = ERFA_DAYSEC;
92  seclim = 60.0;
93 
94 /* Deal with the UTC leap second case. */
95  if ( ! strcmp(scale,"UTC") ) {
96 
97  /* TAI-UTC at 0h today. */
98  js = eraDat(iy, im, id, 0.0, &dat0);
99  if ( js < 0 ) return js;
100 
101  /* TAI-UTC at 12h today (to detect drift). */
102  js = eraDat(iy, im, id, 0.5, &dat12);
103  if ( js < 0 ) return js;
104 
105  /* TAI-UTC at 0h tomorrow (to detect jumps). */
106  js = eraJd2cal ( dj, 1.5, &iy2, &im2, &id2, &w);
107  if ( js ) return js;
108  js = eraDat(iy2, im2, id2, 0.0, &dat24);
109  if ( js < 0 ) return js;
110 
111  /* Any sudden change in TAI-UTC between today and tomorrow. */
112  dleap = dat24 - (2.0*dat12 - dat0);
113 
114  /* If leap second day, correct the day and final minute lengths. */
115  day += dleap;
116  if ( ihr == 23 && imn == 59 ) seclim += dleap;
117 
118  /* End of UTC-specific actions. */
119  }
120 
121 /* Validate the time. */
122  if ( ihr >= 0 && ihr <= 23 ) {
123  if ( imn >= 0 && imn <= 59 ) {
124  if ( sec >= 0 ) {
125  if ( sec >= seclim ) {
126  js += 2;
127  }
128  } else {
129  js = -6;
130  }
131  } else {
132  js = -5;
133  }
134  } else {
135  js = -4;
136  }
137  if ( js < 0 ) return js;
138 
139 /* The time in days. */
140  time = ( 60.0 * ( (double) ( 60 * ihr + imn ) ) + sec ) / day;
141 
142 /* Return the date and time. */
143  *d1 = dj;
144  *d2 = time;
145 
146 /* Status. */
147  return js;
148 
149 }
#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
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
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: