Parse the first length characters of an ISO 8601 string as a Date or DateTz.

Synopsis

Declared in <bdlt_iso8601util.h>

static
int
parse(
    DateOrDateTz* result,
    char const* string,
    ssize_t length,
    ParseConfiguration configuration = ParseConfiguration());

Description

Parse the specified initial length characters of the specified ISO 8601 string as a Date or DateTz value, depending on the presence of a zone designator, and load the value into the specified result, using the optionally specified configuration. Return 0 on success, and a non‐zero value (with no effect) otherwise. string is assumed to be of the form: ` Default: YYYY‐MM‐DD{(+|‐)hh{:}mm|Z} Basic: YYYYMMDD{(+|‐)hh{:}mm|Z} ` Exactly length characters are parsed; parsing will fail if a proper prefix of string matches the expected format, but the entire length characters do not. If the optional zone designator is present in the string, the input is parsed as a DateTz value, and as a Date value otherwise. The behavior is undefined unless 0 <= length.

Return Value

0 on success, and a non‐zero value otherwise

Parameters

Name

Description

result

receives the parsed Date or DateTz

string

ISO 8601 text to parse

length

number of characters to parse

configuration

optional parse configuration

Created with MrDocs