From c60f620cf71893afea6cdd5c8a50a890ecce1810 Mon Sep 17 00:00:00 2001 From: Olivier Ramonat Date: Wed, 11 Dec 2024 09:54:28 +0100 Subject: [PATCH] Use timezone-aware objects to represent datetimes in UTC datetime.utcnow() is deprecated and scheduled for removal in a future version for it/e3-core#30 --- src/e3/date.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/e3/date.py b/src/e3/date.py index ca48de83..3859e245 100644 --- a/src/e3/date.py +++ b/src/e3/date.py @@ -1,7 +1,7 @@ from __future__ import annotations import calendar -from datetime import datetime +from datetime import datetime, timezone import time from typing import overload @@ -27,5 +27,5 @@ def timestamp_as_string(value: float | None) -> str | None: def utc_timestamp() -> int: """Return the number of seconds since epoch UTC.""" - d = datetime.utcnow() + d = datetime.now(tz=timezone.utc) return calendar.timegm(d.utctimetuple())