|
|
|
| Listing 5.7 | |
|
|
|
|
The formula for converting the two conventions for years 'n' B.C. is:
n B.C. = - (n - 1) or -n = (n + 1) B.C.
Thus, 4713 B.C. (historical) is -4712 (astronomical). This routine
necessarily uses the astronomical convention.
*/
#include <math.h>
#include "scdtl_1.h"
double date_to_JD0 (struct DATE_INFO *d)
{
double jd, x, d1, m1, y1;
int d2, m2, y2;
d2 = d->day;
m2 = d->month;
y2 = d->year;
if (y2 == 1582)
{
if (m2 == 10)
{
if (d2 > 4 && d2 < 15)
d2 = 15;
}
}
d1 = (double) d2;
m1 = (double) m2;
y1 = (double) y2;
x = 12 * (y1 + 4800) + m1 - 3;
jd = (2 * (x - floor (x / 12) * 12) + 7 + (365 * x)) / 12;
jd = floor (jd) + d1 + floor (x / 48) - 32083;
if (jd > 2299170L)
jd = jd + floor (x / 4800) - floor (x / 1200) + 38;
return (jd);
}
|
|
|
|
|
|
|
|