C++ Logo

SG16

Advanced search

Subject: Re: LWG issue: Time formatters should not be locale sensitive by default
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2021-04-29 01:52:51


On 29/04/2021 08.37, Corentin via SG16 wrote:
> If you have to mix localized and non localized content, as you can do with numbers, the solution in C++20 would be 
>
> std::format("{:%r} {}", date, std::format(locale::classic(), "{:%r}", date));
>
> The solution in 23 would be, using Jens Idea
>
> std::format("{0:%r} {0:N%r}", date ); // second is not localized
>
> Mixing with numbers:
>
> std::format("{} {:N%r}", 0.0 date ); // not  localized
> std::format("{:L} {:%r}", 0.0 date ); // localized
>
>
> Really easy to understand and not surprising at all. (/s)

Just to clarify: I'm (no longer) suggesting a "N" modifier for
non-locale-sensitive; I'm suggesting to come up with an
entirely new syntax for chrono formatting that disallows
"literals inside format specifiers" and that by default
is non-locale-sensitive, to be consistent with the way
float-formatting works. The existing strftime formatting
is just left alone.

Jens


SG16 list run by sg16-owner@lists.isocpp.org