Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-04-25 06:15:16

From: "Mark Rodgers" <mark.rodgers_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
> >
> > Which appropriate representation? There are many. Short? Long? Two digit
> > year? Four digit? Does it have a weekday?
> The appropriate "appropriate representation"! :-)
> The point is that a strftime format is as flexible as you want. As Darin
> suggested, the string itself can localised like any other string, or you
> can simply use %x, %X and %c to provide reasonable defaults that are
> appropriate for the locale.

Don't get me wrong. Darin is right, I agree with him; iostream manipulators
are a terrible idea as far as localization is concerned, and strftime is
much better. Besides, I'd expect op<< to use the date_put/time_put facets,
not some homegrown manipulators.

I don't think that the strftime solution should be a manipulator, either.
to_string(date, format) is much better.

My point is that, in some cases, it's convenient to provide another level of
indirection on top of strftime. Example:

format("Hello, {1}! Today is {2:%x}.", user, now());

is fine; but

format("Hello, {1}! Today is {2:short_date}.", user, now());

is better. Now you can change the actual strftime format string that
corresponds to short_date at runtime, using a Preferences dialog, for

Boost list run by bdawes at, gregod at, cpdaniel at, john at