Parses a duration string consisting of a possibly signed sequence of decimal numbers, each with an optional fractional part and a unit suffix. The valid suffixes are "ns", "us" "ms", "s", "m", and "h". Simple examples include "300ms", "‐1.5h", and "2h45m". Parses "0" as ZeroDuration(). Parses "inf" and "‐inf" as +/‐ InfiniteDuration().

Synopsis

Declared in <absl/time/time.h>

bool
ParseDuration(
    std::string_view dur_string,
    Duration* d);

Return Value

true upon successful parsing.

Parameters

Name

Description

dur_string

The string to parse.

d

Output parameter receiving the parsed duration.

Created with MrDocs