|
|
@ -35,11 +35,17 @@ def parse_bustime(bustime):
|
|
|
|
parts = bustime.strip().split(':')
|
|
|
|
parts = bustime.strip().split(':')
|
|
|
|
if len(parts) == 2:
|
|
|
|
if len(parts) == 2:
|
|
|
|
hours, mins = parts
|
|
|
|
hours, mins = parts
|
|
|
|
secs = 0
|
|
|
|
secs = "0"
|
|
|
|
elif len(parts) == 3:
|
|
|
|
elif len(parts) == 3:
|
|
|
|
hours, mins, secs = parts
|
|
|
|
hours, mins, secs = parts
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ValueError("Invalid bustime: must be HH:MM[:SS]")
|
|
|
|
raise ValueError("Invalid bustime: must be HH:MM[:SS]")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Reject negative times. Any negative hours should have been removed by now,
|
|
|
|
|
|
|
|
# and we in particular want to reject negative minutes.
|
|
|
|
|
|
|
|
if any(part.startswith("-") for part in (hours, mins, secs)):
|
|
|
|
|
|
|
|
raise ValueError("Invalid bustime: Individual parts cannot be negative")
|
|
|
|
|
|
|
|
|
|
|
|
hours = int(hours)
|
|
|
|
hours = int(hours)
|
|
|
|
mins = int(mins)
|
|
|
|
mins = int(mins)
|
|
|
|
secs = float(secs)
|
|
|
|
secs = float(secs)
|
|
|
|