]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix localized D_T_FMT %c formatting for <chrono> [PR117214]
authorXU Kailiang <xu2k3l4@outlook.com>
Sat, 1 Mar 2025 05:23:21 +0000 (13:23 +0800)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 21 Mar 2025 10:28:15 +0000 (10:28 +0000)
commitc24a1d58bc02daabafd5c94fca0984b70db811c8
treeb7e30df22cc4445af8b0f5a41ab8854138b148e5
parent3c7f2fd8c4b330029c935f2785a5da9395355d7d
libstdc++: Fix localized D_T_FMT %c formatting for <chrono> [PR117214]

Formatting a time point with %c was implemented by calling
std::vprint_to with format string constructed from locale's D_T_FMT
string, but in some locales this string contains strftime specifiers
which are not valid for chrono-specs, e.g. %l. So just use _M_locale_fmt
to avoid this problem.

libstdc++-v3/ChangeLog:

PR libstdc++/117214
* include/bits/chrono_io.h (__formatter_chrono::_M_c): Use
_M_locale_fmt to format %c time point.
* testsuite/std/time/format/pr117214.cc: New test.

Signed-off-by: XU Kailiang <xu2k3l4@outlook.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/include/bits/chrono_io.h
libstdc++-v3/testsuite/std/time/format/pr117214.cc [new file with mode: 0644]