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.

Reply via email to