FACT++  1.0
int eraJdcalf ( int  ndp,
double  dj1,
double  dj2,
int  iymdf[4] 
)

Definition at line 3 of file jdcalf.c.

References eraJd2cal().

Referenced by t_jdcalf().

61 {
62  int j, js;
63  double denom, d1, d2, f1, f2, f;
64 
65 /* Denominator of fraction (e.g. 100 for 2 decimal places). */
66  if ((ndp >= 0) && (ndp <= 9)) {
67  j = 0;
68  denom = pow(10.0, ndp);
69  } else {
70  j = 1;
71  denom = 1.0;
72  }
73 
74 /* Copy the date, big then small, and realign to midnight. */
75  if (dj1 >= dj2) {
76  d1 = dj1;
77  d2 = dj2;
78  } else {
79  d1 = dj2;
80  d2 = dj1;
81  }
82  d2 -= 0.5;
83 
84 /* Separate days and fractions. */
85  f1 = fmod(d1, 1.0);
86  f2 = fmod(d2, 1.0);
87  d1 = floor(d1 - f1);
88  d2 = floor(d2 - f2);
89 
90 /* Round the total fraction to the specified number of places. */
91  f = floor((f1+f2)*denom + 0.5) / denom;
92 
93 /* Re-assemble the rounded date and re-align to noon. */
94  d2 += f + 0.5;
95 
96 /* Convert to Gregorian calendar. */
97  js = eraJd2cal(d1, d2, &iymdf[0], &iymdf[1], &iymdf[2], &f);
98  if (js == 0) {
99  iymdf[3] = (int) (f * denom);
100  } else {
101  j = js;
102  }
103 
104 /* Return the status. */
105  return j;
106 
107 }
int eraJd2cal(double dj1, double dj2, int *iy, int *im, int *id, double *fd)
Definition: jd2cal.c:3

+ Here is the call graph for this function:

+ Here is the caller graph for this function: