Skip to content

Commit

Permalink
T6998: dhcp: fix depracted utcfromtimestamp usage
Browse files Browse the repository at this point in the history
Deprecated as per https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp
Fixes: TypeError: can't subtract offset-naive and offset-aware datetimes

Co-authored-by: Erkki Eilonen <erkki@bearmetal.eu>
  • Loading branch information
erkki and Erkki Eilonen authored Jan 7, 2025
1 parent 08c0054 commit fe50656
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/op_mode/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
lifetime = lease['valid-lft']
expiry = (lease['cltt'] + lifetime)

lease['start_timestamp'] = datetime.utcfromtimestamp(expiry - lifetime)
lease['expire_timestamp'] = datetime.utcfromtimestamp(expiry) if expiry else None
lease['start_timestamp'] = datetime.fromtimestamp(expiry - lifetime, timezone.utc)
lease['expire_timestamp'] = datetime.fromtimestamp(expiry, timezone.utc) if expiry else None

data_lease = {}
data_lease['ip'] = lease['ip-address']
Expand Down

0 comments on commit fe50656

Please sign in to comment.