Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1793
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Wink 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
 
Read Message
Read Message
Previous Topic: FileMove behaviour
Next Topic: Value<int64> and Value<int> mess
Goto Forum:
  


Current Time: Fri Aug 29 22:50:22 CEST 2025

Total time taken to generate the page: 0.04591 seconds