diff --git a/can/io/blf.py b/can/io/blf.py index 64649ebaa..7d944a846 100644 --- a/can/io/blf.py +++ b/can/io/blf.py @@ -103,7 +103,7 @@ def timestamp_to_systemtime(timestamp: float) -> TSystemTime: if timestamp is None or timestamp < 631152000: # Probably not a Unix timestamp return 0, 0, 0, 0, 0, 0, 0, 0 - t = datetime.datetime.fromtimestamp(round(timestamp, 3)) + t = datetime.datetime.fromtimestamp(round(timestamp, 3), tz=datetime.timezone.utc) return ( t.year, t.month, @@ -126,6 +126,7 @@ def systemtime_to_timestamp(systemtime: TSystemTime) -> float: systemtime[5], systemtime[6], systemtime[7] * 1000, + tzinfo=datetime.timezone.utc, ) return t.timestamp() except ValueError: diff --git a/test/logformats_test.py b/test/logformats_test.py index ef446e5d2..a2fd0fe09 100644 --- a/test/logformats_test.py +++ b/test/logformats_test.py @@ -791,7 +791,7 @@ def test_timestamp_to_systemtime(self): def test_issue_1905(self): expected = can.Message( - timestamp=1735650583.491113, + timestamp=1735654183.491113, channel=6, arbitration_id=0x6A9, is_extended_id=False,