FACT++  1.0
int eraCal2jd ( int  iy,
int  im,
int  id,
double *  djm0,
double *  djm 
)

Definition at line 3 of file cal2jd.c.

References ERFA_DJM0.

Referenced by eraDat(), eraDtf2d(), eraUt1utc(), eraUtctai(), palCaldj(), palCldj(), and t_cal2jd().

49 {
50  int j, ly, my;
51  long iypmy;
52 
53 /* Earliest year allowed (4800BC) */
54  const int IYMIN = -4799;
55 
56 /* Month lengths in days */
57  static const int mtab[]
58  = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
59 
60 /* Preset status. */
61  j = 0;
62 
63 /* Validate year and month. */
64  if (iy < IYMIN) return -1;
65  if (im < 1 || im > 12) return -2;
66 
67 /* If February in a leap year, 1, otherwise 0. */
68  ly = ((im == 2) && !(iy%4) && (iy%100 || !(iy%400)));
69 
70 /* Validate day, taking into account leap years. */
71  if ( (id < 1) || (id > (mtab[im-1] + ly))) j = -3;
72 
73 /* Return result. */
74  my = (im - 14) / 12;
75  iypmy = (long) (iy + my);
76  *djm0 = ERFA_DJM0;
77  *djm = (double)((1461L * (iypmy + 4800L)) / 4L
78  + (367L * (long) (im - 2 - 12 * my)) / 12L
79  - (3L * ((iypmy + 4900L) / 100L)) / 4L
80  + (long) id - 2432076L);
81 
82 /* Return status. */
83  return j;
84 
85 }
#define ERFA_DJM0
Definition: erfam.h:90
char id[4]
Definition: FITS.h:71

+ Here is the caller graph for this function: