From 42e97b9b1f14936da16719ecb40fcb1cfa1f0b1d Mon Sep 17 00:00:00 2001 From: Paul Ganssle Date: Fri, 5 Jan 2018 10:30:22 -0500 Subject: [PATCH] Improve Pendulum.now and Pendulum.utcnow performance --- pendulum/pendulum.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pendulum/pendulum.py b/pendulum/pendulum.py index 74a04f5b..cbbf94ac 100644 --- a/pendulum/pendulum.py +++ b/pendulum/pendulum.py @@ -273,11 +273,11 @@ def now(cls, tz=None): return test_instance if tz is None or tz == 'local': - dt = datetime.datetime.now() + dt = datetime.datetime.now(cls._local_timezone()) elif tz is UTC or tz == 'UTC': - dt = datetime.datetime.utcnow().replace(tzinfo=UTC) + dt = datetime.datetime.now(UTC) else: - dt = datetime.datetime.utcnow().replace(tzinfo=UTC) + dt = datetime.datetime.now(UTC) tz = cls._safe_create_datetime_zone(tz) dt = tz.convert(dt) @@ -358,7 +358,7 @@ def create(cls, year=None, month=None, day=None, if cls.has_test_now(): now = cls.get_test_now().in_tz(tz) else: - now = datetime.datetime.utcnow().replace(tzinfo=UTC) + now = datetime.datetime.now(UTC) now = tz.convert(now) if year is None: