- changed status to resolved
When parsing times, 24 should only be allowed for midnight
Issue #15
resolved
Currently, parsing times with additional resolution after hour 24 is allowed:
>>> aniso8601.parse_time('24')
datetime.time(0, 0)
>>> aniso8601.parse_time('24:00')
datetime.time(0, 0)
>>> aniso8601.parse_time('24:00:00')
datetime.time(0, 0)
>>> aniso8601.parse_time('24.1')
datetime.time(0, 6)
>>> aniso8601.parse_time('24:01:00')
datetime.time(0, 0)
>>> aniso8601.parse_time('24:00:01')
datetime.time(0, 0)
The first three correctly indicate midnight, the second three should raise a ValueError
.
From section 4.2.3 ("Midnight") of the spec: "The representations may have reduced accuracy in accordance with 4.2.2.3 or may be designated as a time expression in accordance with 4.2.2.5. To represent midnight the representations may be expanded with a decimal fraction containing only zeros in accordance with 4.2.2.4."
Comments (1)
-
reporter - Log in to comment
When parsing time with hour 24, don't allow minutes or seconds != 0.
Fixes
#15.→ <<cset d296d44ee75d>>