Skip to content

Commit f56d7c9

Browse files
committed
fixed datetime deprecation warning
datetime.utcfromtimestamp() is deprecated, timezone-aware datetime objects should be used instead
1 parent 1fe4760 commit f56d7c9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

enum4linux-ng.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
from argparse import ArgumentParser
8383
from collections import OrderedDict
84-
from datetime import datetime
84+
from datetime import datetime, timezone
8585
import json
8686
import os
8787
import random
@@ -2678,9 +2678,10 @@ def policy_to_human(self, low, high, lockout=False):
26782678
tmp = abs(high) * (1e-7)
26792679

26802680
try:
2681-
minutes = datetime.utcfromtimestamp(tmp).minute
2682-
hours = datetime.utcfromtimestamp(tmp).hour
2683-
time_diff = datetime.utcfromtimestamp(tmp) - datetime.utcfromtimestamp(0)
2681+
dt = datetime.fromtimestamp(tmp, tz=timezone.utc)
2682+
minutes = dt.minute
2683+
hours = dt.hour
2684+
time_diff = dt - datetime.fromtimestamp(0, tz=timezone.utc)
26842685
days = time_diff.days
26852686
except:
26862687
return "invalid time"

0 commit comments

Comments
 (0)