Lot and lot of thanks in advance !
The following code snippet is a function that gives me Year, Month and Day for a given Julian Day..
Can you please tell me what does the constants here signify. I can find this code all over the net but nobody explains about the default values taken here. Also if anyone can explain what the function will do.
Suppose, the value i am passing for JD is 2456447..
VOID GetGregorianDate(LONG JD, PWORD Year, PWORD Month, PWORD Day)
{
LONG j, y, d, m;
j = JD - 1721119; //what is this value - 1721119 (may be related to day.. but how ?)
y = (4 * j - 1) / 146097; //what is this value - 146097 (may be related to year.. but how ?)
j = 4 * j - 1 - 146097 * y;
d = j / 4;
j = (4 * d + 3) / 1461; // ?
d = 4 * d + 3 - 1461 * j;
d = (d + 4) / 4;
m = (5 * d - 3) / 153; // ?
d = 5 * d - 3 - 153 * m;
d = (d + 5) / 5;
y = 100 * y + j;
if (m < 10)
{
m = m + 3;
}
else
{
m = m - 9;
y = y + 1;
}
*Year = (WORD) y;
*Month = (WORD) m;
*Day = (WORD) d;
}