Skip to content

Commit 2dd8d2d

Browse files
committed
Updates create_from_timestamp() method
1 parent 37b4f34 commit 2dd8d2d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pendulum/pendulum.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,21 @@ def create_from_timestamp(cls, timestamp, tz=UTC):
449449
:type timestamp: int or float
450450
451451
:param tz: The timezone
452-
:type tz: TimezoneInfo or str or int or None
452+
:type tz: Timezone or TimezoneInfo or str or int or None
453453
454454
:rtype: Pendulum
455455
"""
456456
dt = datetime.datetime.utcfromtimestamp(timestamp).replace(tzinfo=UTC)
457-
if tz is not UTC and tz != 'UTC':
458-
tz = cls._safe_create_datetime_zone(tz)
457+
instance = cls(
458+
dt.year, dt.month, dt.day,
459+
dt.hour, dt.minute, dt.second, dt.microsecond,
460+
dt.tzinfo
461+
)
459462

460-
dt = tz.convert(dt)
463+
if tz is not UTC and tz != 'UTC':
464+
instance = instance.in_tz(tz)
461465

462-
return cls.instance(dt)
466+
return instance
463467

464468
@classmethod
465469
def strptime(cls, time, fmt):
@@ -733,7 +737,7 @@ def in_tz(self, tz):
733737
Set the instance's timezone from a string or object.
734738
735739
:param value: The timezone
736-
:type value: Timezone or TimezoneInfo or str or None
740+
:type value: Timezone or TimezoneInfo or str or int or None
737741
738742
:rtype: Pendulum
739743
"""

0 commit comments

Comments
 (0)