Title
Time formatters should not be locale sensitive by default
Status
resolved
Section
[time.format]
Submitter
Corentin Jabot

Created on 2021-04-27.00:00:00 last changed 37 months ago

Messages

Date: 2021-10-23.11:04:22

Proposed resolution:

This wording is relative to N4885.

  1. Modify [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.

Date: 2021-10-23.00:00:00

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

Date: 2021-05-15.00:00:00

[ 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."

Date: 2021-04-27.00:00:00

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 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.

History
Date User Action Args
2021-10-23 11:04:22adminsetmessages: + msg12183
2021-10-23 11:04:22adminsetstatus: new -> resolved
2021-05-17 12:23:56adminsetmessages: + msg11804
2021-04-28 16:34:00adminsetmessages: + msg11789
2021-04-27 00:00:00admincreate