Fix timestamp formatting for pcap: convert EDecimal to float for fromtimestamp
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ed6a2cd328
commit
e9a50d9f25
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue