absl::ParseLenientCivilTime

Parses any of the formats accepted by absl::ParseCivilTime(). Unlike ParseCivilTime(), the input string format does not need to match the target civil-time type. Discrepancies are resolved as follows: * Extra components in the input string are ignored. * Missing components are defaulted to their minimum valid values. This behavior is consistent with civil-time converting constructors.

Synopsis

Declared in <absl/time/civil_time.h>

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

Description

Example:

absl::CivilDay d; bool ok = absl::ParseLenientCivilTime("1969-07-20", &d); // OK ok = absl::ParseLenientCivilTime("1969-07-20T10", &d); // OK: T10 floored ok = absl::ParseLenientCivilTime("1969-07", &d); // OK: day defaults to 1

Return Value

true upon successful parsing.

Parameters

NameDescription
sThe string to parse.
cOutput parameter receiving the parsed civil-time value.