4022. Ambiguity in the formatting of negative years with format specifier %C

Section: 30.12 [time.format] Status: New Submitter: Jiang An Opened: 2023-12-08 Last modified: 2023-12-09

Priority: Not Prioritized

View other active issues in [time.format].

View all other issues in [time.format].

View all issues with New status.

Discussion:

Table 101, [tab:time.format.spec] reads:

Table 101 — Meaning of conversion specifiers [tab:time.format.spec]
Specifier Replacement
[…]
%C The year divided by 100 using floored division. If the result is a single decimal digit, it
is prefixed with 0. The modified command %EC produces the locale's alternative
representation of the century.
[…]

When the year is in range [-99, -10], it is unclear whether the result (in range [-9, -1]) is considered as a single decimal digit, and there is implementation divergence (llvm/llvm-project#74727).

Daniel:

This issue is somewhat related to LWG 3831.

Proposed resolution:

This wording is relative to N4964.

[Drafting Note: Two mutually exclusive options are prepared, depicted below by Option A and Option B, respectively.]

Option A:

  1. Modify 30.12 [time.format], Table 101 [tab:time.format.spec], as indicated:

    Table 101 — Meaning of conversion specifiers [tab:time.format.spec]
    Specifier Replacement
    […]
    %C The year divided by 100 using floored division. If the result is a single decimal digitin range [0, 9], it
    is prefixed with 0. The modified command %EC produces the locale's alternative
    representation of the century.
    […]

Option B:

  1. Modify 30.12 [time.format], Table 101 [tab:time.format.spec], as indicated:

    Table 101 — Meaning of conversion specifiers [tab:time.format.spec]
    Specifier Replacement
    […]
    %C The year divided by 100 using floored division. If the result is a single decimal digitin range [-9, 9], it
    is prefixed with 0. The modified command %EC produces the locale's alternative
    representation of the century.
    […]