Let parse_unit_string try int before float.
This commit is contained in:
parent
865c3011e5
commit
7412ef5162
1 changed files with 6 additions and 1 deletions
|
@ -293,14 +293,19 @@ def now(timestamp=True):
|
|||
|
||||
def parse_unit_string(s):
|
||||
'''
|
||||
Try to parse the string as a float, or bytestring, or hms.
|
||||
Try to parse the string as an int, float, or bytestring, or hms.
|
||||
'''
|
||||
if s is None:
|
||||
return None
|
||||
|
||||
s = s.strip()
|
||||
|
||||
if ':' in s:
|
||||
return hms_to_seconds(s)
|
||||
|
||||
elif all(c in '0123456789' for c in s):
|
||||
return int(s)
|
||||
|
||||
elif all(c in '0123456789.' for c in s):
|
||||
return float(s)
|
||||
|
||||
|
|
Loading…
Reference in a new issue