[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 delimited with dashes and colons *and* with the 'T' in it). From everything I've seen (wikipedia, w3.org), that is a valid ISO time stamp. --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 delimited with dashes and colons *and* with the 'T' in it). From everything I've seen (wikipedia, w3.org), that is a valid ISO time stamp.
Hi Chris - Sorry for the slow reply. Indeed, from_iso_string only handles non-delimited iso format. That is: std::string s("19991217T151515"); ptime t = from_iso_string(s); Couple possibilities. 1) strip the '-' and ':' chars before you call from_iso_string. 2) Use the streaming operators with iso extended mode: std::stringstream ss; time_input_facet* input_facet = new time_input_facet(); input_facet->set_iso_extended_format(); ss.imbue(std::locale(ss.getloc(), input_facet)); ss.str("1999-12-17T15:15:15"); ptime t1; ss >> t1; Jeff
participants (2)
-
Chris Webster
-
Jeff Garland