From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 835E83850432; Fri, 28 Jul 2023 17:32:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 835E83850432 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690565568; bh=6do/dnd8OD7xItwHjXOT849vGHS/tMFP0Atvb6Cha74=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nqE2UIkgN5vl+ooYk5Rre0oaWBy3w/4PtKSY7KJeZ68LYXTt+yEpyZUyaDTdw8jMl YP4E7spcXKWqnYBrDfK7L3tjQd/iKk1qoB8Swk9lchRDKtyCtyejGs9xbC/CQAE0Y4 CLdQSpDCpzgMP/FW1DJN/ws1P61YrOnV8lugwVpw= From: "cvs-commit at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110719 --- Comment #5 from CVS Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:cb01a31ab2779b0252c4945924ba2163d9150642 commit r13-7630-gcb01a31ab2779b0252c4945924ba2163d9150642 Author: Jonathan Wakely Date: Tue Jul 18 12:46:07 2023 +0100 libstdc++: Implement correct locale-specific chrono formatting [PR11071= 9] This fixes some TODOs in the C++20 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)=