Created
November 9, 2012 17:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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