C++ Logo


Advanced search

Re: [std-proposals] New draft proposal: Add "%s" (two-digit truncated-integer seconds) as a std::format conversion specifier for std::chrono time types.

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 3 May 2023 19:16:34 -0400
On Wed, May 3, 2023 at 6:49 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On Wednesday, 3 May 2023 09:05:53 PDT Jason McKesson via Std-Proposals wrote:
> > All that being said, there is one clear advantage to your idea: cases
> > where the format string is not known at the site of the use of the
> > format string. The format string could come from a translation file, a
> > macro, or somewhere else. And it would be good if those places could
> > have more control over the formatting precision.
> Is there a real use-case for this? Localised times should just use the
> localised markers.

`format` is supposed to be able to be used for strings that are
non-local. Exactly why they're there isn't really the point. The point
is that the string gets to have a lot of control over the formatting.
You can remap the position of the arguments relative to the format.
You can apply different formatting controls. Etc.

If it's OK for one string to have hours/minutes and one string to have
hours/minutes/seconds, then one should also be able to control the
precision of those seconds. That's just what formats *do*. One format
can have floating-point values with 3 digits of significance, another
can use 5. You don't have to modify the *value* to get that.

Received on 2023-05-03 23:16:47