Epitaffio wrote...
This is my latest version of the function, with the float variables (no code tag = hate)
float iMinPerHour = HoursToSeconds(1)/60; //20
float iMinPerDay = 24 * iMinPerHour; //480
float iMinPerMonth = 28 * iMinPerDay; //13440
float iMinPerYear = 12* iMinPerMonth; //161280
Next of each row, there is an example of the max value (for the year i think we will have only 3 digit, but for testing i've just used the 4 one). I hope it's this what you asked me (i'm not english mother language, so sometimes i misunderstand )
changed this section just a tad. the -1 is to make te numbers 0 based. this makes it easier to exstract your original times back out.
float iMinute = IntToFloat(GetTimeMinute() -1 ); //0
float iHour = GetTimeHour() * iMinPerHour; //(24)*20 480
float iDay = (GetCalendarDay()-1 )* iMinPerDay; //28*480 13440
float iMonth = (GetCalendarMonth()-1 ) * iMinPerMonth; //12*13440 161280
float iYear = GetCalendarYear() * iMinPerYear; //1305*161280 210470400
Yes that is what I needed. So it looks like you are running a server with 20min/hour.
To answer your question: no this will not work. Here is the reasion why.
the single precison float(32 bit) format that nwn uses has only 6 1/2 digits of precision. this means that you can only rely on the value of the 6 most significent digits in the number. lets look at this in relation to your number.
If we have the date/ time
year 6
month 1
day 1
time 0:00
your time stamp would be
6 years *161280min/year
+ (1-1)months * 480min/month
+ (1-1)day * 13440min/day
+ 0hour * 20min/hour
+ 0min
= 967,680min
So for 6 years we have a time stamp of 967,680 minutes. This is no problem and within the limitations of the nwn float.
lets see what year 7 looks like
7 years *161280min/year = 1,128,960
now we have a problem, our number is 7 digits long. the last digit in the number only has a 50% chance of being accurate. This means that if you added a single minute to your time stamp. It might get add it might not. Or it could even add 2 minutes instead of the one your where trying to add.
once you go out to year 70 you would then have 8 digits in the number and adding minutes in blocks of less the 10 would most likely have no effect on your stamp at all. minutes in quanites of less then 100 would have inacurate results but would at least have a chance to effect the stamp.
So the short answer here is No. the float is a bad solution for this method,.
the int on the other hand will give you a number that can go all the way up to 2,147,483,648 with being accurate. that is 9.2 digits of accuracy.
with the method above you coud accuratly store 13,315 years into the int and less then 7 years into the float.