I'm trying to write code to parse date time string using boost 1.55 Date_Time library. But it always produces not-a-date-time date.
boost::gregorian::date d(2005, 6, 25);
boost::gregorian::date d2;
boost::gregorian::date_facet* facet(new boost::gregorian::date_facet("%Y %m %d"));
stringstream ss;
ss.imbue(std::locale(std::cout.getloc(), facet));
ss << d; string s = ss.str(); // s = "2005 06 25"
cout << s << endl;
stringstream ss2(s);
ss2 >> d2; // not-a-date-time
cout << d2 << endl;
I tried different format specifiers, but it didn't help. I'm using Visual C++ 2013. Is there something wrong with my code?
UPDATE:
My system locale is Russian if that makes any difference.