Parses a civil‐time value from the specified absl::string_view into the passed output parameter. Returns true upon successful parsing.

Synopsis

Declared in <absl/time/civil_time.h>

bool
ParseCivilTime(
    std::string_view s,
    CivilSecond* c);

Description

The expected form of the input string is as follows:

Type | Format ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ CivilSecond | YYYY‐MM‐DDTHH:MM:SS CivilMinute | YYYY‐MM‐DDTHH:MM CivilHour | YYYY‐MM‐DDTHH CivilDay | YYYY‐MM‐DD CivilMonth | YYYY‐MM CivilYear | YYYY

Example:

absl::CivilDay d; bool ok = absl::ParseCivilTime("2018‐01‐02", &d); // OK

Parsing tolerates the following variations from the standard format: * Leading and trailing whitespace is ignored. * The year component may be negative (prefixed with '‐') and may contain an arbitrary number of digits. * Sub‐year components (month, day, hour, minute, second) may consist of either one or two digits.

Note that parsing will fail if the string's format does not match the expected type exactly. ParseLenientCivilTime() below is more lenient.

Return Value

true upon successful parsing.

Parameters

Name

Description

s

The string to parse.

c

Output parameter receiving the parsed civil‐time value.

Created with MrDocs