|
Boost Users : |
From: Alexandre Gacon (alexandre.gacon_at_[hidden])
Date: 2006-03-22 11:05:14
Like indicated by Jeff, I forgot to add the imbue call
So you can add to your code:
date_input_facet* pMyFacet = new date_input_facet( "%m-%d-%Y" );
std::locale loc( std::locale::classic(), pMyFacet );
std::istringstream oo;
oo.imbue( loc ); // $$$$$ code added
oo.str( "22-03-2006" );
date myDate;
try
{
oo >> myDate;
date::ymd_type ymd = myDate.year_month_day();
}
catch( std::out_of_range oEx )
{
std::cout << "Error: " << oEx.what() << std::endl;
}
If you want to give more control to the user, check the boost documentation
for the different formats.
Alexandre
-----Message d'origine-----
De : boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] De la part de Christian Henning
Envoyé : mercredi 22 mars 2006 16:56
À : boost-users_at_[hidden]
Objet : Re: [Boost-users] [date_time] How to create
adatefromstringwithspecific format?
I would like to leave that open for the user. My application will support
locals soon and the format of date strings will depend on the local
settings.
So, I'm looking for a general solution for my problem.
Was the code I sent in my last email working on your machine?
Thanks for your input,
Christian
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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