Description
LWG3262 adds:
The result of formatting a std::chrono::duration instance holding a negative value, or of an hh_mm_ss object h for which h.is_negative() is true, is equivalent to the output of the corresponding positive value, with a STATICALLY-WIDEN("-") character sequence placed before the replacement of the leftmost conversion specifier.
[Example:
cout << format("{%:T}", -10'000s); // prints: -02:46:40 cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40 cout << format("{:minutes %M, hours %H, seconds %S}", -10'000s); // prints: minutes -46, hours 02, seconds 40
— end example]
This has a few bugs (fixes already approved on LWG reflector):
cout << format("{%:T}", -10'000s); // prints: -02:46:40
... is wrong. Should be :%T
not %:T
.
cout << format("{:minutes %M, hours %H, seconds %S}", -10'000s); // prints: minutes -46, hours 02, seconds 40
... is wrong; chrono-specs is required to start with a %
. Best we can do here is
cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s); // prints: minutes -46, hours 02, seconds 40
This is misleading:
placed before the replacement of the leftmost conversion specifier.
As noted, the chrono-specs must start with such a conversion specifier. Also,"leftmost" is problematic in an RTL setting. Replace with
placed before the replacement of the
leftmostinitial conversion specifier.