From aac69cc833c627f341d372687903fb6eeb75c5ee Mon Sep 17 00:00:00 2001 From: Andrey Anshin Date: Sat, 3 Feb 2024 21:19:50 +0400 Subject: [PATCH] Avoid usage of deprecated `datetime.datetime.utcfromtimestamp` in `pendulum.from_timestamp` --- src/pendulum/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pendulum/__init__.py b/src/pendulum/__init__.py index 3863b760..a4a37111 100644 --- a/src/pendulum/__init__.py +++ b/src/pendulum/__init__.py @@ -292,11 +292,7 @@ def from_timestamp(timestamp: int | float, tz: str | Timezone = UTC) -> DateTime """ Create a DateTime instance from a timestamp. """ - dt = _datetime.datetime.utcfromtimestamp(timestamp) - - dt = datetime( - dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond - ) + dt = DateTime.fromtimestamp(timestamp, tz=UTC) if tz is not UTC or tz != "UTC": dt = dt.in_timezone(tz)