Fix last seen timestamp parsing to handle both ISO and SQLite timestamp...

Fix last seen timestamp parsing to handle both ISO and SQLite timestamp formats for proper timezone display
parent 53a58cdd
......@@ -105,8 +105,14 @@ def api_stats():
# Parse the timestamp string and convert to Unix timestamp
from datetime import datetime
if isinstance(client['last_seen'], str):
# Assume ISO format like '2023-10-08T12:34:56.789Z'
dt = datetime.fromisoformat(client['last_seen'].replace('Z', '+00:00'))
# Handle different timestamp formats
ts_str = client['last_seen']
if 'T' in ts_str:
# ISO format like '2023-10-08T12:34:56.789Z'
dt = datetime.fromisoformat(ts_str.replace('Z', '+00:00'))
else:
# SQLite format like '2025-10-08 08:45:43'
dt = datetime.strptime(ts_str, '%Y-%m-%d %H:%M:%S')
last_seen_ts = dt.timestamp()
else:
last_seen_ts = time.mktime(client['last_seen'].timetuple())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment