Skip to content

Commit

Permalink
fix: [crashlogs] more precise time
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Nov 27, 2024
1 parent 39f3d10 commit 5156d80
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/sysdiagnose/parsers/crashlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ def parse_ips_file(path: str) -> list | dict:
lines = f.readlines()

result['report'] = CrashLogsParser.process_ips_lines(lines)
try:
# captureTime is more precise than the timestamp
timestamp = None
if 'captureTime' in result['report']: # captureTime is more precise than the timestamp
timestamp = datetime.strptime(result['report']['captureTime'], '%Y-%m-%d %H:%M:%S.%f %z')
except Exception:
elif 'date' in result['report']:
timestamp = datetime.strptime(result['report']['date'], '%Y-%m-%d %H:%M:%S.%f %z')

if not timestamp:
timestamp = datetime.strptime(result['timestamp'], '%Y-%m-%d %H:%M:%S.%f %z')
result['timestamp_orig'] = result['timestamp']
result['datetime'] = timestamp.isoformat(timespec='microseconds')
result['timestamp'] = timestamp.timestamp()
return result
Expand Down

0 comments on commit 5156d80

Please sign in to comment.