libstdc++: Fix std::format output of %C for negative years
commita01462ae8bafa86e7df47a252917ba6899d587cf
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Dec 2023 15:33:59 +0000 (11 15:33 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 12 Dec 2023 22:33:32 +0000 (12 22:33 +0000)
tree82f8a46d4a2062aa0218c745b696479596e48ec5
parent988dd6384c88a110952833dfe7c8344b9af95fa4
libstdc++: Fix std::format output of %C for negative years

During discussion of LWG 4022 I noticed that we do not correctly
implement floored division for the century. We were just truncating
towards zero, rather than applying the floor function. For negative
values that rounds the wrong way.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Fix
rounding for negative centuries.
* testsuite/std/time/year/io.cc: Check %C for negative years.
libstdc++-v3/include/bits/chrono_io.h
libstdc++-v3/testsuite/std/time/year/io.cc