Skip to content

Commit 5d62394

Browse files
authored
Refactor timestamp factor calculations to use constants (#1933)
1 parent 6deca6e commit 5d62394

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

can/io/blf.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class BLFParseError(Exception):
9999
TIME_TEN_MICS = 0x00000001
100100
TIME_ONE_NANS = 0x00000002
101101

102+
TIME_TEN_MICS_FACTOR = Decimal("1e-5")
103+
TIME_ONE_NANS_FACTOR = Decimal("1e-9")
104+
102105

103106
def timestamp_to_systemtime(timestamp: float) -> TSystemTime:
104107
if timestamp is None or timestamp < 631152000:
@@ -269,7 +272,7 @@ def _parse_data(self, data):
269272
continue
270273

271274
# Calculate absolute timestamp in seconds
272-
factor = Decimal("1e-5") if flags == 1 else Decimal("1e-9")
275+
factor = TIME_TEN_MICS_FACTOR if flags == 1 else TIME_ONE_NANS_FACTOR
273276
timestamp = float(Decimal(timestamp) * factor) + start_timestamp
274277

275278
if obj_type in (CAN_MESSAGE, CAN_MESSAGE2):

0 commit comments

Comments
 (0)