From 0cc66e8e3cf82085526961efdac33896d98b2480 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Sat, 21 Dec 2024 09:13:06 +0530 Subject: [PATCH] fix warning (#3338) --- dev/generate-kernel-signatures.py | 13 ++++++++++--- dev/generate-tests.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/dev/generate-kernel-signatures.py b/dev/generate-kernel-signatures.py index 7038d95f7f..c3eb23f3ee 100644 --- a/dev/generate-kernel-signatures.py +++ b/dev/generate-kernel-signatures.py @@ -143,9 +143,16 @@ def reproducible_datetime(): - build_date = datetime.datetime.utcfromtimestamp( - int(os.environ.get("SOURCE_DATE_EPOCH", time.time())) - ) + import sys + + timestamp = int(os.environ.get("SOURCE_DATE_EPOCH", time.time())) + + if sys.version_info >= (3, 11): + build_date = datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC) + else: + build_date = datetime.datetime.utcfromtimestamp( + int(os.environ.get("SOURCE_DATE_EPOCH", time.time())) + ) return build_date.isoformat().replace("T", " AT ")[:22] diff --git a/dev/generate-tests.py b/dev/generate-tests.py index 48c90b3a59..07e6d3d2c3 100644 --- a/dev/generate-tests.py +++ b/dev/generate-tests.py @@ -19,9 +19,16 @@ def reproducible_datetime(): - build_date = datetime.datetime.utcfromtimestamp( - int(os.environ.get("SOURCE_DATE_EPOCH", time.time())) - ) + import sys + + timestamp = int(os.environ.get("SOURCE_DATE_EPOCH", time.time())) + + if sys.version_info >= (3, 11): + build_date = datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC) + else: + build_date = datetime.datetime.utcfromtimestamp( + int(os.environ.get("SOURCE_DATE_EPOCH", time.time())) + ) return build_date.isoformat().replace("T", " AT ")[:22]