Reuse tm_writer in weekday formatter

This commit is contained in:
Vladislav Shchapov 2021-11-13 22:45:25 +05:00 committed by Victor Zverovich
parent 8b89454994
commit 50140be7ae

View File

@ -1663,8 +1663,10 @@ template <typename Char> struct formatter<weekday, Char> {
auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) {
auto time = std::tm();
time.tm_wday = static_cast<int>(wd.c_encoding());
return detail::write<Char>(
ctx.out(), time, detail::get_locale(localized, ctx.locale()), 'a');
detail::get_locale loc(localized, ctx.locale());
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
w.on_abbr_weekday();
return w.out();
}
};