This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.
3844. Non-numeric formats for negative durationsSection: 30.12 [time.format] Status: Open Submitter: Jonathan Wakely Opened: 2022-12-20 Last modified: 2023-02-10
Priority: 3
View other active issues in [time.format].
View all other issues in [time.format].
View all issues with Open status.
Discussion:
The wording of 30.12 [time.format] p4 seems to have some unwanted consequences. It says:
The result of formatting astd::chrono::duration
instance holding a negative value, or anhh_mm_ss
objecth
for whichh.is_negative()
istrue
, is equivalent to the output of the corresponding positive value, with aSTATICALLY-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.
[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 30.12 [time.format] as indicated:
Option A
-4- The result of formatting a
std::chrono::duration
instance holding a negative value, or a nchrono::hh_mm_ss
objecth
for whichh.is_negative()
istrue
, is equivalent to the output of the corresponding positive value, with aSTATICALLY-WIDEN<charT>("-")
character sequence placed before the replacement of the initial first 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 The result of formatting a
std::chrono::duration
instance holding a negative value, or a nchrono::hh_mm_ss
objecth
for whichh.is_negative()
istrue
, is equivalent to the output of the corresponding positive value, with aSTATICALLY-WIDEN<charT>("-")
character sequence placed before the replacement of the initial conversion specifier.
Proposed resolution:
This wording is relative to N4928.
Modify 30.12 [time.format] as indicated:
-4- The result of formatting a
std::chrono::duration
instance holding a negative value, or a nchrono::hh_mm_ss
objecth
for whichh.is_negative()
istrue
, is equivalent to the output of the corresponding positive value, with aSTATICALLY-WIDEN<charT>("-")
character sequence placed before the replacement of the initial first conversion specifier that is one of %H, %I, %M, %S, or %T.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4