SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.37k stars 472 forks source link

Fix handling dates earlier than 1900 in Oracle backend #1136

Closed JaroslawCendrowski closed 3 months ago

JaroslawCendrowski commented 3 months ago

Solves https://github.com/SOCI/soci/issues/1135

vadz commented 3 months ago

I think this solves the problem for the years between 1800 and 1900, but not those earlier than 1800, right? This is probably better than nothing, but it looks like we could easily solve it for any negative tm_year in the same way.

But beyond this I also wonder if this actually works in the other backends. It would be great to add a unit test checking for this to the "std::tm" section of the corresponding test in tests/common-tests.h.

JaroslawCendrowski commented 3 months ago

It fixes years starting from 1. Didn't test for years BC yet.

I think this solves the problem for the years between 1800 and 1900, but not those earlier than 1800, right? This is probably better than nothing, but it looks like we could easily solve it for any negative tm_year in the same way.

But beyond this I also wonder if this actually works in the other backends. It would be great to add a unit test checking for this to the "std::tm" section of the corresponding test in tests/common-tests.h.

JaroslawCendrowski commented 3 months ago

Test added. It fails with current implementation, works with my changes in standard-use-type.cpp.

I think this solves the problem for the years between 1800 and 1900, but not those earlier than 1800, right? This is probably better than nothing, but it looks like we could easily solve it for any negative tm_year in the same way.

But beyond this I also wonder if this actually works in the other backends. It would be great to add a unit test checking for this to the "std::tm" section of the corresponding test in tests/common-tests.h.

vadz commented 3 months ago

Thanks, I'm (squash) merging this now!

P.S. Oracle "excess-100 notation" is really weird, I wonder who came up with something like this and why.