
Christian Henning wrote:
Alexandre, the following code will give an exception stating "Error: Year is out of valid range: 1400..10000". I don't think the myDate object is correctly initialized. Can you check this on your machine, please. Can you call myDate.year_month_day()?
date_input_facet* pMyFacet = new date_input_facet( "%m-%d-%Y" );
std::locale loc( std::locale::classic(), pMyFacet );
std::istringstream oo; oo.str( "22-03-2006" );
date myDate; ...snip...
I'd say the format in the facet and the data don't match -- there is no month 22. If you want the string 22-03-2006 to work try date_input_facet( "%d-%m-%Y" ) Also, you will need to imbue the facet into the stringstream: oo.imbue(locale(oo.getloc(), date_input_facet)) This is why you are getting the year out of range exception -- because the default format for dates expects the year first and 22 is out of range. Jeff