Boost logo

Boost :

From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2003-07-10 08:53:41

Jeff Garland wrote:
> On Wed, 09 Jul 2003 09:33:44 -0400, Stefan Seefeld wrote
>>hi there,
>>what is the suggested way to persist a time_duration into a string ?
>>I tried 'to_iso_string' but there is no corresponding
>>'duration_from_iso_string'. Shouldn't that exist (if only for
>>symmetry) ?
> Yes it should be there for symmetry. Give this a shot:
> using boost::posix_time;
> std::string tds; //.. your duration string
> time_duration td =
> boost::date_time::parse_undelimited_time_duration<time_duration>(tds);
> This doesn't look like it will handle fractional seconds, but maybe you don't
> need that...

yes, I do need that. I'm recording certain events to be able to play
them back later on, so I store the 'current time' along.

Right now I'm doing things:

// recording...

// at the start of the recording...
origin = pt::microsec_clock::local_time();
// and for each event...
std::string tstamp =
   pt::to_simple_string(pt::microsec_clock::local_time() - origin);

// playback...
pt::time_duration time = pt::duration_from_string(tstamp);


Boost list run by bdawes at, gregod at, cpdaniel at, john at