Home » U++ Library support » U++ Core » Date is broken for years below one.
|
Re: Date is broken for years below one. [message #26544 is a reply to message #26542] |
Mon, 10 May 2010 18:15 |
|
Hi Novo,
Quite similar topic was discussed here few months ago, see this thread.
As someone noted Quote: | not many dates are known so detailed from the years before 1582
|
I don't think this is a serious problem. Most of the algorithms using date should work just fine.
If you really need to count days, you can try to fix Date::Get() and Date::Set(). They contain just plain arithmetics, but it gets tricky when year<=0 It is because of how the integral division works. For starter, I *think* that Date::Get)) should be int Date::Get() const {
return year * 365 + s_month_off[month - 1] + (day - 1) +
(year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + (year>0) +
(month > 2) * IsLeapYear(year);
}
For Date::Set() it is bit more complicated, there you would have to add similar correction and additionally also add few more if blocks, because now all the ifs for counting leap years check just for (d>=...).
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Sat Apr 27 17:36:37 CEST 2024
Total time taken to generate the page: 0.04414 seconds
|