Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix several bugs in the LWG3262 wording #3810

Closed
zygoloid opened this issue Feb 28, 2020 · 0 comments
Closed

fix several bugs in the LWG3262 wording #3810

zygoloid opened this issue Feb 28, 2020 · 0 comments

Comments

@zygoloid
Copy link
Member

zygoloid commented Feb 28, 2020

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 leftmost initial conversion specifier.

@cplusplus cplusplus deleted a comment from timsong-cpp Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant