From 50140be7ae201d8e48d7c91d0ff2b9c334994ff4 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sat, 13 Nov 2021 22:45:25 +0500 Subject: [PATCH] Reuse tm_writer in weekday formatter --- include/fmt/chrono.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index c74207b3..47ea3dbb 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1663,8 +1663,10 @@ template struct formatter { auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) { auto time = std::tm(); time.tm_wday = static_cast(wd.c_encoding()); - return detail::write( - ctx.out(), time, detail::get_locale(localized, ctx.locale()), 'a'); + detail::get_locale loc(localized, ctx.locale()); + auto w = detail::tm_writer(loc, ctx.out(), time); + w.on_abbr_weekday(); + return w.out(); } };