From c71ae712c336cee10f72069faf2bada3dead7c61 Mon Sep 17 00:00:00 2001 From: Jevin Sweval Date: Tue, 17 Sep 2024 12:54:28 -0400 Subject: [PATCH] BlockWithTimestampMixin: add setter for `timestamp` --- pcapng/blocks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pcapng/blocks.py b/pcapng/blocks.py index 2c9abab..f39ae77 100644 --- a/pcapng/blocks.py +++ b/pcapng/blocks.py @@ -341,6 +341,13 @@ def timestamp(self): (self.timestamp_high << 32) + self.timestamp_low ) * self.timestamp_resolution + @timestamp.setter + def timestamp(self, timestamp: float | int): + its = int(round(timestamp / self.timestamp_resolution)) + self.timestamp_high = (its >> 32) & 0xFFFF_FFFF + self.timestamp_low = its & 0xFFFF_FFFF + + @property def timestamp_resolution(self): return self.interface.timestamp_resolution