From 4726d9ea65e2276413d94a89a475d01ac19f1294 Mon Sep 17 00:00:00 2001 From: Frederik Reiter Date: Sat, 20 Jul 2024 23:57:38 +0200 Subject: [PATCH] fix: Create timezone-aware datetime for Objects Use `.fromtimestamp` instead of `.utcfromtimestamp` to create a timezone-aware datetime object. Previously, the object was naive. `.utcfromtimestamp` is deprecated because naive datetime objects lead to ambiguity and problems. By using a datetime-aware object, is is clearly signaled to the caller that the datetime is a UTC-timestamp, and it may easily be converted using `.astimezone` --- vt/object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vt/object.py b/vt/object.py index 58153e1..d3fcfde 100644 --- a/vt/object.py +++ b/vt/object.py @@ -160,7 +160,7 @@ def __getattribute__(self, attr: str) -> typing.Any: value = super().__getattribute__(attr) for r in Object.DATE_ATTRIBUTES: if r.match(attr): - value = datetime.datetime.utcfromtimestamp(value) + value = datetime.datetime.fromtimestamp(value, datetime.UTC) break return value