When using std::time_put to format a chrono value, we should imbue the formatting locale into the stream. This ensures that when std::time_put::do_put uses a ctype or __timepunct facet from the locale, it gets the correct facets.
libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__formatter_chrono::_M_locale_fmt): Imbue locale into ostringstream. --- This doesn't cause a problem with any existing formatters, but is needed for the next patches in this series. I'll try to come up with a standalone testcase that depends on this fix (involving a custom facet derived from std::time_put which uses the locale in its do_put). Tested x86_64-linux. libstdc++-v3/include/bits/chrono_io.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index c16b555df29..55ebd4ee061 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -1697,6 +1697,7 @@ namespace __format char __fmt, char __mod) const { basic_ostringstream<_CharT> __os; + __os.imbue(__loc); const auto& __tp = use_facet<time_put<_CharT>>(__loc); __tp.put(__os, __os, _S_space, &__tm, __fmt, __mod); if (__os) -- 2.48.1