[whatwg] Time Parsing

   The algorithm to parse a time component contains a bug.

When parsing the seconds, the spec states:

   "Collect a sequence of characters that are either characters in the
    range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) or U+002E FULL
    STOP characters. If the collected sequence has more than one U+002E
    FULL STOP characters, or if the last character in the sequence is a
    U+002E FULL STOP character, then fail. Otherwise, let the collected
    string be second instead of its previous value."

This is incorrect because it allows the second component to contain more 
than 2 digits before the decimal point.  i.e. "00:00:012.345" would 
parsed without error.

The algorithm should instead state to look for 2 digits representing the 
seconds, then check if there's a decimal point, and then check for the 
fractional part of the second.

This should also only allow up to 3 digits representing milliseconds. 
If there are 4 or more digits (microseconds or beyond), the spec should 
state that the remaining digits should be truncated.

e.g. "00:00:00.9999"

Technically, that would be 999,900?s, but it needs to be rounded down to 
999ms, not rounded up to 1s.


Lachlan Hunt - Opera Software

Received on Monday, 28 March 2011 08:06:57 UTC