Fix timestamp formatting for pcap: convert EDecimal to float for fromtimestamp

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Robert McMahon 2026-02-16 17:44:33 -08:00
parent ed6a2cd328
commit e9a50d9f25
1 changed files with 6 additions and 2 deletions

View File

@ -419,8 +419,12 @@ class CaptureAnalyzer:
@staticmethod
def _format_timestamp(pkt):
"""Format packet timestamp as HH:MM:SS.mmm."""
if hasattr(pkt, 'time') and pkt.time:
dt = datetime.fromtimestamp(pkt.time)
if hasattr(pkt, 'time') and pkt.time is not None:
try:
ts = float(pkt.time) # pcap can give EDecimal; fromtimestamp needs int/float
except (TypeError, ValueError):
return "N/A"
dt = datetime.fromtimestamp(ts)
return dt.strftime("%H:%M:%S.%f")[:-3] # Truncate to milliseconds
return "N/A"