diff options
author | metron2 <metron2@users.noreply.github.com> | 2025-01-06 17:55:13 -0500 |
---|---|---|
committer | Indrajit Raychaudhuri <irc@indrajit.com> | 2025-01-26 12:31:31 -0600 |
commit | 529c24a9d550b30ba7fabcbae3a5bc0d5d35c647 (patch) | |
tree | 4cbb42bec5484f4122875aac02a37697f44adad3 /src | |
parent | 10ee7ac1d2bfd20bd11b5ebaa33c2f07dd561d48 (diff) | |
download | vyos-1x-529c24a9d550b30ba7fabcbae3a5bc0d5d35c647.tar.gz vyos-1x-529c24a9d550b30ba7fabcbae3a5bc0d5d35c647.zip |
T6998: dhcpy.py - fix datetime to be timezone aware
Diffstat (limited to 'src')
-rwxr-xr-x | src/op_mode/dhcp.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/op_mode/dhcp.py b/src/op_mode/dhcp.py index b3d7d4dd3..7091808e0 100755 --- a/src/op_mode/dhcp.py +++ b/src/op_mode/dhcp.py @@ -19,6 +19,7 @@ import sys import typing from datetime import datetime +from datetime import timezone from glob import glob from ipaddress import ip_address from tabulate import tabulate @@ -110,10 +111,8 @@ def _get_formatted_server_leases(raw_data, family='inet'): ipaddr = lease.get('ip') hw_addr = lease.get('mac') state = lease.get('state') - start = lease.get('start') - start = _utc_to_local(start).strftime('%Y/%m/%d %H:%M:%S') - end = lease.get('end') - end = _utc_to_local(end).strftime('%Y/%m/%d %H:%M:%S') if end else '-' + start = datetime.fromtimestamp(lease.get('start'), timezone.utc) + end = datetime.fromtimestamp(lease.get('end'), timezone.utc) if lease.get('end') else '-' remain = lease.get('remaining') pool = lease.get('pool') hostname = lease.get('hostname') @@ -138,10 +137,8 @@ def _get_formatted_server_leases(raw_data, family='inet'): for lease in raw_data: ipaddr = lease.get('ip') state = lease.get('state') - start = lease.get('last_communication') - start = _utc_to_local(start).strftime('%Y/%m/%d %H:%M:%S') - end = lease.get('end') - end = _utc_to_local(end).strftime('%Y/%m/%d %H:%M:%S') + start = datetime.fromtimestamp(lease.get('last_communication'), timezone.utc) + end = datetime.fromtimestamp(lease.get('end'), timezone.utc) if lease.get('end') else '-' remain = lease.get('remaining') lease_type = lease.get('type') pool = lease.get('pool') |