Skip to content

Commit

Permalink
set timezone to utc
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 committed Jan 1, 2025
1 parent e69b168 commit b4e3e3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion can/io/blf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion test/logformats_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b4e3e3d

Please sign in to comment.