I am writing a class for holding dates in c++, and I found the following problem:
I have a number of days N
since a reference date (in
I have a number of days N since a reference date (in my case that would be Jan 1, 0001 AD)...
In that case, "efficiency" in applying the 4-100-400 rule and looking up month lengths is not your main problem. Please be also aware of the multiple problems inherent in applying today's Gregorian calendar to dates predating its inception, and the fact that Gregorian was not introduced uniformly. (*)
Wikipedia is a good starting point to a very involved subject.
(*): Depending on country, anywhere between 15 October 1582 and 15 February 1923, resp. not at all, actually.