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); ...
Regards, Stefan
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost