|
Boost : |
From: Martin (adrianm_at_[hidden])
Date: 2005-04-23 11:00:07
> Why not drop facets altogether and use a stream format manipulator instead:
>
> std::cout << set_date_format("%Y-%b-%d") << mydate << std::endl;
The problem with manipulators is that you need access to the stream. How do
you use manipulators with lexical cast and program options?
> You could still have a facet if you really wanted uses to change the
> *algorithm* used for io, but I guess what I'm trying to say is that:
>
> algorithms go in facets.
> configuration data goes in the iostream object itself.
I'd say that the date format is a localization thing and as such belong in a
facet. The standard is consistant on keeping localization things in facets
However, the standard is broken when it comes to date and time issues which
makes it difficult.
Normally format specifiers are in one facet (num_punct, money_punct) while the
actual formatting/parsing occurs in another (num_put/get, money_put/get).
For date_time there is no time_punct facet (anyone know why?).
The standard only says that time_put formats the date as specifed in a
strftime format string. It says nothing about where this string should come
from. Maybe the intention was to allow the date format as a modifier but I
doubt it since it makes it impossible to implement time_get correctly (how do
you parse '%x').
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk