parseDateAndTime

Parses a combined date and time in a format specified in ISO 8601:2004.

Returns the number of characters used to compose a valid date and time. Zero is returned if a complete date and time cannot be extracted. In that case, the value of the resulting Time or ExtendedDate is undefined.

This function is stricter than just calling parseDate followed by parseTime: there are no allowances for expanded years or reduced dates (two-digit years), and separator usage must be consistent.

Although the standard allows for omitting the T between the date and the time, this function requires it.

  1. size_t parseDateAndTime(T[] src, DT dt)
    size_t
    parseDateAndTime
    (
    T
    )
    (
    T[] src
    ,
    ref DT dt
    )
  2. size_t parseDateAndTime(T[] src, FullDate fd)

Examples

Time t;

// January 1st, 2008 00:01:00
parseDateAndTime("2007-12-31T23:01-01", t);

// April 12th, 1985 23:50:30,042
parseDateAndTime("1985W155T235030,042", t);

// Invalid time: returns zero
parseDateAndTime("1902-03-04T10:1a", t);

// Separating T omitted: returns zero
parseDateAndTime("1985-04-1210:15:30+04:00", t);

// Inconsistent separators: all return zero
parseDateAndTime("200512-01T10:02",          t);
parseDateAndTime("1985-04-12T10:15:30+0400", t);
parseDateAndTime("1902-03-04T050607",        t);

Meta