Skip to content

[libc++] Should formatting year{-99} with %C produce "-1" or "-01"? #74727

@StephanTLavavej

Description

@StephanTLavavej

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

check(SV("%C='-1'\t%y='99'\t%Y='-0099'\t\n"), fmt, std::chrono::year{-99});
check(SV("%C='-1'\t%y='09'\t%Y='-0009'\t\n"), fmt, std::chrono::year{-9});

For year{-99} and year{-9}, this test expects %C='-1', but MSVC's STL emits %C='-01'. This Standardese isn't exactly a paragon of crystal clarity, but I think this might be a bug in libc++. (Otherwise, it's a bug in MSVC's STL that we'll need to fix.)

Metadata

Metadata

Assignees

Labels

formatC++20 std::format or std::print, and anything related to themlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions