get gregorian time/day from JulianDay bug?

ndesle

23-04-2009 15:45:31

Hi,

I have a problem converting Caelum's JulianDay back into gregorian calendar. Here's the code I use:

For setting the initial time for Caelum:

int startYear = 2009;
int startMonth = 7;
int startDay = 1;
int startHour = 14;
int startMinutes = 0;
int startSeconds = 0;
m_CaelumSystem->getUniversalClock()->setGregorianDateTime( startYear, startMonth, startDay, startHour, startMinutes, startSeconds );


For extracting the current date/time again (for displaying the time of day on screen)

int year;
int month;
int day;
int hours;
int minutes;
Caelum::LongReal seconds;

julianDay = m_CaelumSystem->getJulianDay();
Caelum::Astronomy::getGregorianDateTimeFromJulianDay( julianDay, year, month, day, hours, minutes, seconds );

char tmps[256];
sprintf_s( tmps, 256, "%.2d:%.2d:%.2d", hours, minutes, (int) floor( seconds ));

OverlayElement* timePanel = OverlayManager::getSingleton().getOverlayElement("Common/Time");
timePanel->setCaption( tmps );


I set the initial time to be 14:00:00, and the timescale is 0 at first (so time does not advance).
If I try to extract the time again and print it, it shows 12:00:00.
If I start advancing time, the hours stay at 12:00:00 for a while, then suddenly shift to 18:00:00.
The julianDay value I get from Caelum at 14:00:00 is 2455014.0833333335. When I try entering this value in an on-line julianDay to gregorian converter applet, it correctly returns what I was expecting.

Does anyone have any idea what I'm doing wrong?

Regards
Nils Desle

xadh00m

23-04-2009 16:30:54

Did you check this thread first? viewtopic.php?f=21&t=9384

xad

ndesle

24-04-2009 09:36:25

Ah, that was the problem. Weird that I didn't find this when doing a search in the forum :? ('cause I did, honestly!)

Thanks!