C++ Logo

SG16

Advanced search

Subject: Re: LWG issue: Time formatters should not be locale sensitive by default
From: Tom Honermann (tom_at_[hidden])
Date: 2021-04-27 09:56:02


I agree with this direction, though perhaps we should simply drop locale
support until we're ready to make it work in an encoding correct manner.

Tom.

On 4/27/21 3:29 AM, Corentin via SG16 wrote:
> In [time.format], it is specified
>
> > Some of the conversion specifiers depend on the locale that is
> passed to the formatting function if the latter takes one, or the
> global locale otherwise
>
> This is not consistent with the format design after the adoption of P1892
> In [format.string.std] we say:
>
> > When the L option is used, the form used for the conversion is
> called the locale-specific form. The L option is only valid for
> arithmetic types, and its effect depends upon the type
>
> This has 2 issues:
> First, it is inconsistent.
>
> format("{}, 0.0"); // locale independent
> format("{:L}", 0.0); // use locale
> format("{:%r}, some_time); // use globale locale
> format("{:%rL}, some_time); // error
>
> And second it perpetuates the issues P1892 intended to solve.
> It is likely that this inconsistency resulted from both papers being
> in flight around the same time
>
> Proposed resolution
>
> The L option should be used and consistent with floating point. We
> suggest using the C locale which is the non-locale locale.
> (https://pubs.opengroup.org/onlinepubs/009604499/basedefs/xbd_chap07.html)
>
> Suggested wording
>
> Modify [time.format]/1
>
> /chrono-format-spec: /
> /    fill-and-align(opt) width(opt) precision(opt)
> chrono-specs(opt)L(opt)/
>
> Modify [time.format]/2
>
> Each conversion specifier conversion-spec is replaced by appropriate
> characters as described in Table 101; the formats specified in ISO
> 8601:2004 shall be used where so described. Some of the conversion
> specifiers depend on <del>the locale that is passed to the formatting
> function if the latter takes one, or the global locale otherwise</del>
> _<ins>a locale. If the L option is used, that locale is the locale
> that is passed to the formatting function if the later takes one, or
> the global locale otherwise. If the L option is not used, that locale
> is the "C" locale</ins>_.If the formatted object does not contain the
> information the conversion specifier refers to, an exception of type
> format_error is thrown.
>
>
>
>



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