date_time icon indicating copy to clipboard operation
date_time copied to clipboard

Dates before 1400-01-01

Open ev1313 opened this issue 2 years ago • 1 comments

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?

ev1313 avatar Sep 18 '22 10:09 ev1313

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.

JeffGarland avatar Sep 20 '22 01:09 JeffGarland