Understanding caelum time...


26-06-2009 03:20:44

First of all: congratulations and many thanks, caelum (and the port caelumSharp) is a great plugin.

I'm using it for the first time on a project that requires dynamic day/night and many features that turn around atmosferic conditions (caelum was a pefect match) but I'm having some trouble on dealing with the timestamps that Caelum features: Julian Calendar.

I'm asking this, because I believe that many of you here have a great deal of experience alongside Caelum and surely do this in a simple/quick way:
a - how do you determine wether its night or day?
b - how do you determine which weather season are we currently at?

My current solution for this is:
a - parsing by hand the remainer of the float number, and determine wether its larger than 0.3 and smaller than 0.8 (representing somewhere beetween 7.2 AM and 19.2PM )... which determines the day period. Is there a better/smarter way?
b - I'm not solving it, I'm simply defining by hand a sum of days which I'll consider winter and trigger my special events at winter. (Can work for now..like this :D )

Also, when i read this here I noticed that you might use some tricks like the stated in the wiki text:
If the Julian date of noon is applied to the entire midnight-to-midnight civil day centered on that noon,[5] rounding Julian dates (fractional days) for the twelve hours before noon up while rounding those after noon down, then the remainder upon division by 7 represents the day of the week, with 0 representing Monday, 1 representing Tuesday, and so forth. Now at 22:03, Monday June 22, 2009 (UTC) the nearest noon JDN is 2455005 yielding a remainder of 0.

I understand the decision of Julian date for computational reasons and for Caelum system, and it suits very well, I just wanted to explore if there are clever conversions.. since I'm a newb at this.

Thanks for the time consumed in reading this.


30-06-2009 16:30:02

You can determine the current time of the day with:

int year;
int month;
int day;
int hour;
int minute;
double second;

Caelum::Astronomy::getGregorianDateTimeFromJulianDay(mCaelumSystem->getJulianDay(), year, month, day, hour, minute, second);

A season is an arbitrary date period. So you'll need to define those periods as you see fit. boost::gregorian has some nice classes to deal with date_periods.



04-07-2009 22:59:01

Yeah, I went that way.
I defined the Winter time (it was my season to define) by hand, so whenever it returns a certain amount of days passed, it goes into winter mode (just a lil' of the precipitation compositor with snow tex).

Once again, thanks.