提前非常感谢!
下面的代码片段是一个函数,它为我提供给定儒略日的年、月和日。
你能告诉我这里的常数是什么意思吗?我可以在网上找到这段代码,但没有人解释这里采用的默认值。另外,如果有人可以解释该功能将做什么。
假设,我为 JD 传递的值是 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;
}