stealth977
27-02-2009 13:25:33
Below is the fix to the getGregorianDateTimeFromJulianDay(....) function not working properly (at least under VS2008 SP1)
the problem was HighPrecision mode not activated in the function so hour/minute/second was not working since they are the parts needing high precision.
Now the set and get functions properly roundtrip![Smile :)]({SMILIES_PATH}/icon_smile.gif)
the problem was HighPrecision mode not activated in the function so hour/minute/second was not working since they are the parts needing high precision.
Now the set and get functions properly roundtrip
![Smile :)]({SMILIES_PATH}/icon_smile.gif)
void Astronomy::getGregorianDateTimeFromJulianDay(
LongReal julianDay, int &year, int &month, int &day,
int &hour, int &minute, LongReal &second)
{
// Integer julian days are at noon.
// static_cast<int)(floor( is more precise than Ogre::Math::IFloor.
// Yes, it does matter.
int fpmode = enterHighPrecissionFloatingPointMode();
julianDay += (LongReal)0.5;
int ijd = static_cast<int>(floor(julianDay));
getGregorianDateFromJulianDay(ijd, year, month, day);
LongReal s = (julianDay - (LongReal)ijd);
s *= 86400.0;
hour = static_cast<int>(floor(s / 3600));
s -= hour * 3600;
minute = static_cast<int>(floor(s / 60));
s -= minute * 60;
second = s;
restoreFloatingPointMode(fpmode);
}