Skip to content

fix several bugs in the LWG3262 wording #3810

Closed
@zygoloid

Description

@zygoloid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions