I am trying to use boost :: date_time to parse a date string (obtained from the Twitter API) into a ptime object. Date format example:
Thu Mar 24 16:12:42 +0000 2011
No matter what I do, I get a βYear out of rangeβ exception when trying to parse a string. The date format looks correct for me, here is the code:
boost::posix_time::ptime created_time; std::stringstream ss(created_string); ss.exceptions(std::ios_base::failbit); //Turn on exceptions ss.imbue(std::locale(ss.getloc(), new boost::posix_time::time_input_facet("%a %b %d %T %q %Y"))); ss >> created_time;
The "created_string" code above contains the date above. Did I make a mistake in the format string?
c ++ boost datetime parsing
Kazade
source share