From 3b4a18b379afda64ae0b441cf2b6449a64fbc4e7 Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 4 Jan 2025 17:09:33 +0100 Subject: [PATCH] Also added the ValueError raise condition for `lastconnect` datetime. --- src/meshctrl/device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshctrl/device.py b/src/meshctrl/device.py index d9ed2ab..bb017c1 100644 --- a/src/meshctrl/device.py +++ b/src/meshctrl/device.py @@ -106,7 +106,7 @@ class Device(object): if not isinstance(lastconnect, datetime.datetime) and lastconnect is not None: try: lastconnect = datetime.datetime.fromtimestamp(lastconnect) - except OSError: + except (OSError, ValueError): # Meshcentral returns in miliseconds, while fromtimestamp, and most of python, expects the argument in seconds. Try seconds frist, then translate from ms if it fails. # This doesn't work for really early timestamps, but I don't expect that to be a problem here. lastconnect = datetime.datetime.fromtimestamp(lastconnect/1000.0)