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.
Section: 30.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 30.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 28.5.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. TheL
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.
TheL
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.
Modify 30.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 onthe locale that is passed to the formatting function if the latter takes one, or the global locale otherwisea locale. If theL
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 theL
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 typeformat_error
is thrown.