This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.

3547. Time formatters should not be locale sensitive by default

Section: 29.12 [time.format] Status: Resolved Submitter: Corentin Jabot Opened: 2021-04-27 Last modified: 2021-10-23

Priority: 2

View other active issues in [time.format].

View all other issues in [time.format].

View all issues with Resolved status.

Discussion:

In 29.12 [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 22.14.2.2 [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 two 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.

The L option should be used and consistent with floating point. We suggest using the C locale which is the non-locale locale, see also here.

[2021-05-17; Reflector poll]

Priority set to 2. This will be resolved by P2372. Tim noted: "P1892 didn't change format's ignore-locale-by-default design, so that paper being in flight at the same time as P1361 cannot explain why the latter is locale-sensitive-by-default."

[2021-10-23 Resolved by the adoption of P2372R3 at the October 2021 plenary. Status changed: New → Resolved.]

Proposed resolution:

This wording is relative to N4885.

  1. Modify 29.12 [time.format] as indicated:

    chrono-format-spec:
             fill-and-alignopt widthopt precisionopt Lopt chrono-specsopt
    […]
    

    -1- […]

    -2- Each conversion specifier conversion-spec is replaced by appropriate characters as described in Table [tab:time.format.spec]; the formats specified in ISO 8601:2004 shall be used where so described. 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 otherwisea locale. If the L option is used, that locale is the locale that is passed to the formatting function if the latter takes one, or the global locale otherwise. If the L option is not used, that locale is the "C" locale. If the formatted object does not contain the information the conversion specifier refers to, an exception of type format_error is thrown.