Skip to content

ValueError: could not convert string to float, on packet.sniff_time, when using use_ek=True #718

@tuokri

Description

@tuokri

Describe the bug

Traceback (most recent call last):
  File "S:\PyCharmProjects\project\venv\Lib\site-packages\pyshark\packet\packet.py", line 87, in sniff_time
    timestamp = float(self.sniff_timestamp)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '2024-11-25T13:45:37.622961000Z'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "S:\PyCharmProjects\project\project\analyze.py", line 467, in <module>
    main()
  File "S:\PyCharmProjects\project\project\analyze.py", line 327, in main
    if (start_date <= (sniff_time := packet.sniff_time.astimezone(dt.timezone.utc)) <= stop_date)
                                     ^^^^^^^^^^^^^^^^^
  File "S:\PyCharmProjects\project\venv\Lib\site-packages\pyshark\packet\packet.py", line 91, in sniff_time
    timestamp = float(self.sniff_timestamp.split(".")[0])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '2024-11-25T13:45:37'

To Reproduce
Try to use packet.sniff_time.

cap = pyshark.FileCapture(pcapng_path, use_ek=True, include_raw=False)
for packet in cap:
    print(packet.sniff_time)

Versions (please complete the following information):

  • OS: Windows 11
  • pyshark version: 0.6
  • tshark version: TShark (Wireshark) 4.4.2 (v4.4.2-0-g9947b17309f4).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions