Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2007-03-28 23:44:20


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net