Skip to content

Commit aac69cc

Browse files
committed
Avoid usage of deprecated datetime.datetime.utcfromtimestamp in pendulum.from_timestamp
1 parent 3e3fec6 commit aac69cc

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/pendulum/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,7 @@ def from_timestamp(timestamp: int | float, tz: str | Timezone = UTC) -> DateTime
292292
"""
293293
Create a DateTime instance from a timestamp.
294294
"""
295-
dt = _datetime.datetime.utcfromtimestamp(timestamp)
296-
297-
dt = datetime(
298-
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond
299-
)
295+
dt = DateTime.fromtimestamp(timestamp, tz=UTC)
300296

301297
if tz is not UTC or tz != "UTC":
302298
dt = dt.in_timezone(tz)

0 commit comments

Comments
 (0)