public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110719] Should chrono formatters always use std::time_put for locale's representation? Date: Fri, 28 Jul 2023 17:32:47 +0000 [thread overview] Message-ID: <bug-110719-4-WyhnvfWwsC@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110719-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110719 --- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:cb01a31ab2779b0252c4945924ba2163d9150642 commit r13-7630-gcb01a31ab2779b0252c4945924ba2163d9150642 Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Jul 18 12:46:07 2023 +0100 libstdc++: Implement correct locale-specific chrono formatting [PR110719] This fixes some TODOs in the C++20 <chrono> format support, where the locale-specific output was incorrect or unimplemented. The approach taken here is to either use the formatting locale's std::time_put facet to do the formatting, or to remove subsecond precision from time points so that locale-specific formats don't print fractional seconds. This ensures that we are consistent with what the std::time_put facet would print (which never includes fractional seconds) even if we actually reimplement the formatting by hand instead of using the facet. This also fixes a misplaced statement that allowed modifiers for %Z which should have been on %z instead. There was also some ill-formed code in an untested branch for formatting time zone names to wide characters. A new test for zoned_time I/O has been added to exercise that code properly. libstdc++-v3/ChangeLog: PR libstdc++/110719 * include/bits/chrono_io.h (__formatter_chrono::_M_parse): Fix allowed modifiers for %z and %Z. Fix -Wparentheses and -Wnarrowing warnings. (__formatter_chrono::_M_format): Call new functions for %d, %e, %H, %I, %m and %M. (__formatter_chrono::_M_c): Use _S_floor_seconds to remove subsecond precision. (__formatter_chrono::_M_C_y_Y): Use _M_locale_fmt to handle modifiers. (__formatter_chrono::_M_e): Replace with _M_d_e and use _M_locale_fmt. (__formatter_chrono::_M_I): Replace with _M_H_I and use _M_locale_fmt. (__formatter_chrono::_M_m): New function. (__formatter_chrono::_M_M): New function. (__formatter_chrono::_M_r): Use _M_locale_fmt. (__formatter_chrono::_M_S): Likewise. (__formatter_chrono::_M_u_w): Likewise. (__formatter_chrono::_M_U_V_W): Likewise. (__formatter_chrono::_M_X): Use _S_floor_seconds. (__formatter_chrono::_M_Z): Fix untested branch for wchar_t. (__formatter_chrono::_S_altnum): Remove function. (__formatter_chrono::_S_dd_zero_fill): Remove function. (__formatter_chrono::_S_floor_seconds): New function. (__formatter_chrono::_M_locale_fmt): New function. * testsuite/std/time/clock/system/io.cc: Adjust expected output for locale-specific formats and check modified formats. * testsuite/std/time/clock/utc/io.cc: Likewise. * testsuite/std/time/zoned_time/io.cc: New test. (cherry picked from commit f4bce119f617dc4663fb43f55784908daf16b4b6)
next prev parent reply other threads:[~2023-07-28 17:32 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-18 14:43 [Bug libstdc++/110719] New: " redi at gcc dot gnu.org 2023-07-19 10:13 ` [Bug libstdc++/110719] " redi at gcc dot gnu.org 2023-07-19 10:37 ` redi at gcc dot gnu.org 2023-07-19 11:37 ` cvs-commit at gcc dot gnu.org 2023-07-19 11:39 ` redi at gcc dot gnu.org 2023-07-19 15:51 ` cvs-commit at gcc dot gnu.org 2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org [this message] 2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org 2023-07-28 18:59 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110719-4-WyhnvfWwsC@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).