Also added the ValueError raise condition for lastconnect datetime.

This commit is contained in:
Daan
2025-01-04 17:09:33 +01:00
parent c072d6012a
commit 3b4a18b379

View File

@@ -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)