From 2e7ce63b51c73dbc665b803f655435d979a50664 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 31 Aug 2026 23:22:41 +0200 Subject: [PATCH] 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. --- confluent_server/aiohmi/util/parse.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/confluent_server/aiohmi/util/parse.py b/confluent_server/aiohmi/util/parse.py index b7fd0783..57bbfe79 100644 --- a/confluent_server/aiohmi/util/parse.py +++ b/confluent_server/aiohmi/util/parse.py @@ -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