Created on 2022-12-20.00:00:00 last changed 21 months ago
Proposed resolution:
This wording is relative to N4928.
Modify [time.format] as indicated:
-4- The result of formatting a
std::chrono::duration instance holding a negative value, or anchrono::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<charT>("-") character sequence placed before the replacement of theinitialfirst conversion specifier that is one of %H, %I, %M, %S, or %T.
[ Issaquah 2023-02-10; LWG issue processing ]
Set priority to 3. Proposed a hybrid resolution.
Previous resolution [SUPERSEDED]:
Two alternatives are presented, choose one of Option A or Option B.
Modify [time.format] as indicated:
Option A
-4- The result of formatting a
std::chrono::duration instance holding a negative value, or anchrono::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<charT>("-") character sequence placed before the replacement of theinitialfirst conversion specifier that is not one of %n, %p, %q, %t, or %%.Option B
-4- Among the specifiers, %H, %I, %M, %S, and %T, the
Theresult of formatting astd::chrono::duration instance holding a negative value, or anchrono::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<charT>("-") character sequence placed before the replacement of the initial conversion specifier.
The wording of [time.format] p4 seems to have some unwanted consequences. It says:
The result of formatting a std::chrono::duration instance holding a negative value, or 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<charT>("-") character sequence placed before the replacement of the initial conversion specifier.
Taken literally, I think that means:
format("{:%q}", -1s) == "-s" format("{:%t%j}", -25h) == "-\t1" format("{:%p%I}", -11h) == "-am11"
The last one probably doesn't matter (what does -11am mean anyway?) but some of them do matter, for example something like "{:(%q)%t%Q}" intends to put the unit suffix first in parens but will print "(-s)\t1" which probably isn't what the user wanted.
I think we want to place the sign before the first numeric conversion specifier, not "the initial conversion specifier". That is what Howard's date::format and <fmt> both do.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-02-10 18:21:41 | admin | set | messages: + msg13340 |
2023-02-10 18:21:41 | admin | set | status: new -> open |
2022-12-20 12:57:05 | admin | set | messages: + msg13166 |
2022-12-20 00:00:00 | admin | create |