ptime::from_iso_string() & time_from_string()
Neither of the functions I listed in the title seem to support a time of the format: 1999-12-17T15:15:15 (that is with the 'T' in it). From everything I've seen (wikipedia, w3.org), that is a valid ISO time stamp. Also how do I search the archives? I could get to the page, but no search feature seemed to be present... Thanks, Chris
Chris Webster wrote:
Neither of the functions I listed in the title seem to support a time of the format: 1999-12-17T15:15:15 (that is with the 'T' in it). From everything I've seen (wikipedia, w3.org), that is a valid ISO time stamp.
Yeah, it is, but from_iso_string only supports the non-delimited form: Try this: std::string s("19991217T151515"); ptime t = from_iso_string(s); std::cout << t << std::endl; If you want extended form use the time_input_facet with iso_extended mode set: 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; This is the more robust way to do this anyway. Jeff
participants (2)
-
Chris Webster
-
Jeff Garland