[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug libstdc++/110504] std::format("{:%S}", duration<long, std::ratio<1,2>>(4)) returns "02.0" inste
From: "redi at gcc dot gnu.org via Gcc-bugs" <gcc-bugs () gcc ! gnu ! org>
Date: 2023-06-30 23:16:24
Message-ID: bug-110504-4-4K2tIuYOhY () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110504
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I have a patch to fix this:
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -1079,7 +1079,9 @@ namespace __format
{
locale __loc = _M_locale(__ctx);
auto __ss = __hms.subseconds();
- if constexpr (is_floating_point_v<rep>)
+ if (__ss == __ss.zero())
+ ; // Do not write all-zero fractional part.
+ else if constexpr (is_floating_point_v<rep>)
{
__out = std::format_to(__loc, std::move(__out),
_GLIBCXX_WIDEN("{:.{}Lg}"),
However the example in [time.clock.utc.nonmembers] suggests that in fact
printing the zeros is correct. The sys_time<milliseconds> value is printed as
"2015-06-30 23:59:60.000 UTC" which would be altered by the patch above.=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic