getting boost::gregorian dates from a string
- by Chris H
I asked a related question yesterday
http://stackoverflow.com/questions/2612343/basic-boost-date-time-input-format-question
It worked great for posix_time ptime objects. I'm have trouble adapting it to get Gregorian date objects.
try {
stringstream ss;
ss << dateNode->GetText();
using boost::local_time::local_time_input_facet;
//using boost::gregorian;
ss.imbue(locale(locale::classic(),
new local_time_input_facet("%a, %d %b %Y ")));
ss.exceptions(ios::failbit);
ss>>dayTime;
} catch (...) {
cout<<"Failed to get a date..."<<endl;
//cout<<e.what()<<endl;
throw;
}
The dateNode-GetText() function returns a pointer to a string of the form
Sat, 10 Apr 2010 19:30:00
The problem is I keep getting an exception. So concretely the question is, how do I go from const char * of the given format, to a boost::gregorian::date object?
Thanks again.