Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2007-04-21 14:11:16


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk