fmt/include
Tiago 3a0661d7c0
Don't construct a locale when formatting year_month_day (#4940)
formatter<year_month_day>::format passes true to get_locale, so every default
format constructs a std::locale, and tm_writer then compares it against the
classic locale (is_classic_(loc_ == get_classic_locale())). The only thing
written is on_iso_date(), which is pure arithmetic and reads neither loc_ nor
is_classic_.

It is the odd one out among its siblings: formatter<day> and formatter<year>
pass false; formatter<weekday> and formatter<month> pass their localized()
flag. Only year_month_day hardcodes true, and its parse() never sets localized
in the first place.

With FMT_USE_LOCALE=0 this costs more than a copy: the loc.get<std::locale>()
arm of get_locale is compiled out, so it default-constructs instead, capturing
the current global locale in a build that asked for no locale support.

No output change: chrono_test.year_month_day already sets a non-classic global
locale and expects "2024-01-01".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-13 08:30:16 -07:00
..
fmt Don't construct a locale when formatting year_month_day (#4940) 2026-09-13 08:30:16 -07:00