Boost logo

Boost Users :

From: Bart (bartmann.nsd_at_[hidden])
Date: 2006-02-04 08:15:21


"Christian Henning" <chhenning_at_[hidden]> wrote in message
news:949801310602031343y1d2ade2maf8d09ae5be1e604_at_mail.gmail.com...
> Hi there, I'm trying to format a time string based on a
> local_time_facet. For some reason it isn't working as expected. Here
> is the code (I basically copied from the Date Time IO Tutorial):
>
> ptime t( microsec_clock::local_time() );
>
> std::stringstream ss;
>
> local_time_facet* output_facet = new local_time_facet();
> ss.imbue( std::locale( std::locale::classic(), output_facet));
>
> output_facet->format("%a %b %d, %H:%M %z");
> ss.str("");
> ss << t;
> std::cout << ss.str() << std::endl;
>
> The output isn't formated in the way it's specified. Cout will
> basically spit out the same result as to_simple_string().
>
> 2006-Feb-03 16:38:57.046875

That would be because you are attempting to use a local_time_facet to output
a ptime.

Use either a time_facet to output a ptime object, or a local_time_facet to
output a local_date_time object.

Bart


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