Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-02-20 21:13:04


On Mon, 20 Feb 2006 18:17:24 -0500, Christian Henning wrote
> Not sure, if I understand you correctly. Have you tried date_facets
> to imbue stringstreams? There you can define the format of dates.
>
> Something, like this:
>
> date d(2005,06,25);
>
> date_facet date_output;

Just as a note: this code is likely to crash when the stringstream is
destroyed and date_output is deleted. You'll want to dynamically allocate
these facets as shown in the date-time docs.

> stringstream ss;
> ss.imbue( locale(ss.getloc(), &date_output) );
>
> date_output.format("%Y-%B-%d");
>
> ss << d;
>
> string strDate = ss.str();
>
> Is it what you are asking for?

The formats, the strings used for things like month and day names -- basically
anything can be replacecd using the facets as Christian indicates. There is
an I/O tutorial in the documents that shows how to do this. Good places to read:

http://www.boost.org/doc/html/date_time/date_time_io.html#date_time.io_tutorial
http://www.boost.org/doc/html/date_time/date_time_io.html

HTH,

Jeff


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net