boostorg / date_time

Boost.org date_time module
http://boost.org/libs/date_time
Boost Software License 1.0
67 stars 95 forks source link

Dates before 1400-01-01 #217

Open ev1313 opened 2 years ago

ev1313 commented 2 years ago

Hi,

I want to use boost::date_time with dates before 1400, which is currently not possible. In the best case I'd like to use dates before 0, but I would be fine with dates after 0 also. My current suboptimal solution is just accepting wrong dates by substracting a fixed amount of years from the date when displaying them.

Any hints how I could solve this problem?

JeffGarland commented 2 years ago

So I think your best bet might be to customize your boost install by changing the greg_year specification to allow dates prior to 1400. The 1400 is a sort of arbitrary decision point to allow things to work with integer sizes and supporting up to year 9999. If you make this change, some unit tests will likely fail, but the algorithms should be fine:

https://github.com/boostorg/date_time/blob/develop/include/boost/date_time/gregorian/greg_year.hpp#L28

also you'd likely want to change this line as well to match:

https://github.com/boostorg/date_time/blob/develop/include/boost/date_time/gregorian/greg_year.hpp#L24

As for dates less than 0, I'm far less certain that this would work.