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: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 3 May 2023 22:02:23 -0500
Perhaps the answer is to generalise this proposal, by allowing the format
string to specify a possibly dynamic number of decimal digits that may be
zero? I can envisage wanting to display milliseconds or microseconds almost
as often as wanting to display whole seconds.

On Wed, May 3, 2023, 18:16 Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> 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.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-05-04 03:02:37