Skip to content

Instantly share code, notes, and snippets.

@dolanor
Created November 9, 2012 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dolanor/4046864 to your computer and use it in GitHub Desktop.
Save dolanor/4046864 to your computer and use it in GitHub Desktop.
Use date facets to parse more string format defined by the ISO. Taken from http://boost.2283326.n4.nabble.com/ptime-from-iso-string-amp-time-from-string-td2566283.html
// Instead of this
std::string s("19991217T151515");
ptime t = from_iso_string(s);
std::cout << t << std::endl;
// Use this
time_input_facet* input_facet = new time_input_facet();
input_facet->set_iso_extended_format();
std::stringstream ss;
ss.imbue(std::locale(ss.getloc(), input_facet));
ss.str("1999-12-17T15:15:15");
ptime t1;
ss >> t1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment