Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-02-25 18:31:20


On Sun, 26 Feb 2006 00:50:04 +0200, Yuval Ronen wrote
> Hi.
> I've used the date_time I/O using facets and found it too
> complicated. The thing that bothers me is that I need to use a facet
> to specify the format string (e.g "HH:MM:SS"). This is burdensome.
> IMO, using facets is fine for defining things which are really
> locale-related (and are mostly constant during the process lifetime)
> such as the month names in the local language.

Of course the order of dates *is* locale related. Even in the current
standard library there is information in date facet about ordering.

> The format is not
> such a property and can often change throughout the application, and
> as such is much better handled using an I/O manipulator:
>
> cout << time_format("HH:MM:SS") << my_ptime << endl;
>
> or if this is impossible, then
>
> cout << time_io(my_ptime, "HH:MM:SS") << endl;

Shouldn't we stick to the current set of format strings which is consistent
with the current standards?

      cout << time_format("%H:%M:%s") << my_ptime << endl;

> which surely is possible.
>
> I think of specifying the format string as similar to specifying the
> printing precision of a float, or specifying that an integer should
> be printed as hex. These are provided as manipulators without the
> complexity of facets (which most users, including me, know very
> little about).
>
> BTW, this is not my original idea. I saw it in a post (don't
> remember by whom) in this mailing list a few months ago.

Sure this would be nice and it has been discussed before. The i/o code is
implemented in a way that should allow for this. Patches certainly accepted.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk