[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Progress with time



Below is the algorithm that Cary sent me.  If I crank in the data, and use 
the mjd formula,
then I come out 1/2 day off by some dates the Jure sent me:

2001-03-11 at 0 UT should come out 2451979.5
2000-01-01 at 12:00 should be 2451545

To match these two dates, I have to add .5 to the formula below.  Can 
anyone check this?

Note I am putting in the 4 digit year and month without adding the one as 
indicated in the code below.

Tom Droege


Here's that code I was talking about...
This is the straight up C code listing....
/***********************************************************/
* juldate calculates jd and mjd */
/***********************************************************/
void juldate()
{
float j1,j2,j4,j5; *** Variable Declarations and Initialzations***
year =local->tm_year+1900; *** Variable Declarations and
Initialzations***
month =local->tm_mon+1; *** Variable Declarations and
Initialzations***
day =local->tm_mday; *** Variable Declarations and Initialzations***
hour =local->tm_hour; *** Variable Declarations and Initialzations***
min =local->tm_min; *** Variable Declarations and Initialzations***
tsec =local->tm_sec; *** Variable Declarations and Initialzations***
sec = (float)tsec + ((float)imilsec / 1000.); *** Variable Declarations
and Initialzations***
j1=-678987.0+(367*year);
j2=(int)(275*month/9);
j4=-(int)(7*(year+((month+9)/12))/4);
j5=(j1+(j2+day+j4));
lastfive=j5;
mjd=-678987.0+367.0*year+(int)((int)(275*month/9)+day-(int)(7*(year+(int)((m 
onth+9)/12))/4))+(hour*3600.0+min*60.0+sec)*1.15740741E-5;
juliandate=(j5+2400000.5);
return;
}