From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A2D8385734A; Wed, 19 Jul 2023 11:37:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A2D8385734A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689766655; bh=qPeDTelvfIWE6NC/rIegP0c2kfL+lwLZSZO5zJSXTyw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=K/CGQpRs2Ve/QE/bO0woBapma5z6D+Qfx/0thLlV01NRXizShnZxom0BP55lXp8Qu nIT5mFUvQDVecx1vm88llQaYUhJR77lO4tEQP4DNS9frBZ485vvXDoFmPdXWA8bT37 EVweMgkEBaJOeRclIZIqjUOMKeAHg2qT7qez9o1Y= 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: Wed, 19 Jul 2023 11:37:35 +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 #2 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:f4bce119f617dc4663fb43f55784908daf16b4b6 commit r14-2640-gf4bce119f617dc4663fb43f55784908daf16b4b6 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.=