diff --git a/aprslib/parsing/common.py b/aprslib/parsing/common.py index 185215b..dd8d9cd 100644 --- a/aprslib/parsing/common.py +++ b/aprslib/parsing/common.py @@ -99,7 +99,8 @@ def parse_timestamp(body, packet_type=''): else: timestamp = "19700101000000" - timestamp = int((utc.strptime(timestamp, "%Y%m%d%H%M%S") - datetime(1970, 1, 1)).total_seconds()) + td = utc.strptime(timestamp, "%Y%m%d%H%M%S") - datetime(1970, 1, 1) + timestamp = int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6) except Exception as exp: timestamp = 0 logger.debug(exp) diff --git a/tests/test_parse_common.py b/tests/test_parse_common.py index fc4c84a..64190dc 100644 --- a/tests/test_parse_common.py +++ b/tests/test_parse_common.py @@ -179,7 +179,8 @@ class TimestampTC(unittest.TestCase): def test_timestamp_valid(self): date = datetime.utcnow() - timestamp = int((date - datetime(1970, 1, 1)).total_seconds()) + td = date - datetime(1970, 1, 1) + timestamp = int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6) # hhmmss format body = date.strftime("%H%M%Shtext")