fix: replace deprecated datetime.utcfromtimestamp()/utcnow() calls (#268)

Both APIs are deprecated since Python 3.12 and scheduled for removal.

- aprsd/packets/core.py: datetime.utcfromtimestamp(ts)
    -> datetime.fromtimestamp(ts, tz=timezone.utc)

- aprsd/plugins/time.py: pytz.datetime.datetime.utcnow()
    -> datetime.now(timezone.utc).replace(tzinfo=None)
  (naive UTC returned to preserve pytz.utc.localize() contract)

- tests/plugins/test_time.py: same fix in test setup

Closes #249
This commit is contained in:
2026-08-28 14:41:36 -04:00
committed by GitHub
parent 868cb8c3dc
commit 08deaab94e
4 changed files with 11 additions and 4 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
import datetime as _dt
from unittest import mock
import pytz
@@ -15,7 +16,7 @@ class TestTimePlugins(test_plugin.TestPlugin):
@mock.patch('aprsd.plugins.time.TimePlugin._get_local_tz')
@mock.patch('aprsd.plugins.time.TimePlugin._get_utcnow')
def test_time(self, mock_utcnow, mock_localtz):
utcnow = pytz.datetime.datetime.utcnow()
utcnow = _dt.datetime.now(_dt.timezone.utc).replace(tzinfo=None)
mock_utcnow.return_value = utcnow
tz = pytz.timezone('US/Pacific')
mock_localtz.return_value = tz