mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-04 20:17:58 +00:00
Read a fractional second as a fraction
parse_time read the digits after the decimal point as whole milliseconds, so '.5' became 5ms instead of 500ms. Only a three digit fraction came out right, and a BMC may write either. '.5', '.50' and '.500' are all 500ms now, '.125' is 125ms. Every other format parse_time accepts is untouched.
This commit is contained in:
@@ -42,9 +42,10 @@ def parse_time(timeval):
|
||||
secs = secs * 60 * positive
|
||||
ms = None
|
||||
if '.' in timeval:
|
||||
timeval, ms = timeval.split('.', 1)
|
||||
ms = int(ms)
|
||||
ms = timedelta(0, 0, 0, ms)
|
||||
# A decimal fraction of a second. Read as whole
|
||||
# milliseconds, '.5' came out as five of them.
|
||||
timeval, fraction = timeval.split('.', 1)
|
||||
ms = timedelta(seconds=float('0.' + fraction))
|
||||
retval = datetime.strptime(timeval, '%Y-%m-%dT%H:%M:%S')
|
||||
if ms:
|
||||
retval += ms
|
||||
|
||||
Reference in New Issue
Block a user