parseTime

Parses a time of day in a format specified in ISO 8601:2004.

Returns the number of characters used to compose a valid time: 0 if no time can be composed.

Fields in dt will either be correct or the default, which is 0 for all time-related fields. fields. Unless one is absolutely sure that midnight can never be encountered, one should check the return value to be sure that the parsing succeeded as expected.

Extra fields in ExtendedDate:

Seconds may be 60 if the hours and minutes are 23 and 59, as leap seconds are occasionally added to UTC time. A Time's seconds will be 59 in this case.

Hours may be 0 or 24: the latter marks the end of a day and the former the beginning, although they both refer to the same instant in time. A Time will be precisely 00:00 in either case.

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

Examples

Time t;
ExtendedDate ed;

// ",000" omitted for clarity
parseTime("20",             t); // 20:00:00
parseTime("2004",           t); // 20:04:00
parseTime("20:04:06",       t); // 20:04:06
parseTime("16:49:30,001",   t); // 16:49:30,001
parseTime("16:49:30,1",     t); // 16:49:30,100
parseTime("16:49,4",        t); // 16:49:24
parseTime("23:59:60",      ed); // 23:59:60
parseTime("24:00:01",       t); // 00:00:00; return value is 5
parseTime("24:00:01",      ed); // 00:00:00; return value is 5; endOfDay
parseTime("30",             t); // 00:00:00; return value is 0
parseTime("21:32:43-12:34", t); // 10:06:43; day increased by one

Meta