Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aprslib/parsing/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from math import sqrt
from datetime import datetime
from datetime import datetime, timezone
from aprslib import base91
from aprslib.exceptions import ParseError
from aprslib.parsing import logger
Expand Down Expand Up @@ -80,7 +80,7 @@ def parse_timestamp(body, packet_type=''):
match = re.findall(r"^((\d{6})(.))$", body[0:7])
if match:
rawts, ts, form = match[0]
utc = datetime.utcnow()
utc = datetime.now(timezone.utc)

timestamp = 0

Expand Down
6 changes: 3 additions & 3 deletions tests/test_parse_common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import string
from random import randint, randrange, sample
from datetime import datetime
from datetime import datetime, timezone

from aprslib import base91
from aprslib.parsing.common import *
Expand Down Expand Up @@ -178,8 +178,8 @@ def test_status_timestamp_invalid(self):
})

def test_timestamp_valid(self):
date = datetime.utcnow()
td = date - datetime(1970, 1, 1)
date = datetime.now(timezone.utc)
td = date - datetime(1970, 1, 1, tzinfo=timezone.utc)
timestamp = int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6)

# hhmmss format
Expand Down