Function cras::parseDuration

Function Documentation

::rclcpp::Duration cras::parseDuration(const ::std::string &s)

Parse the given string as duration.

This function accepts this general format:

However, many modifications of the format are supported:

  • The delimiter can be any of :-/_ (or empty string) and it doesn’t need to be consistent in the string.

  • The fields do not need to be zero-padded and can overflow their natural limit up to UINT32_MAX.

  • If no delimiters are present (except maybe the decimal dot), the number is treated as the number of seconds.

  • Decimal comma , can be used instead of decimal dot . .

Parameters:

s[in] The string to parse.

Throws:

std::invalid_argument – If the string does not represent a duration.

Returns:

The parsed duration.