Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Function template parse_delimited_time_duration

boost::date_time::parse_delimited_time_duration — Creates a time_duration object from a delimited string.


// In header: <boost/date_time/time_parsing.hpp>

template<typename time_duration> 
  time_duration parse_delimited_time_duration(const std::string & s);


Expected format for string is "[-]h[h][:mm][:ss][.fff]". If the number of fractional digits provided is greater than the precision of the time duration type then the extra digits are truncated.

A negative duration will be created if the first character in string is a '-', all other '-' will be treated as delimiters. Accepted delimiters are "-:,.".