Skip to content

Commit

Permalink
Avoid usage of deprecated datetime.datetime.utcfromtimestamp in `pe…
Browse files Browse the repository at this point in the history
…ndulum.from_timestamp`
  • Loading branch information
Taragolis committed Feb 3, 2024
1 parent 3e3fec6 commit aac69cc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/pendulum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aac69cc

Please sign in to comment.