Skip to content

Commit

Permalink
Merge pull request #1 from mkenigs/fix-now-tz
Browse files Browse the repository at this point in the history
Fix now(tz)
  • Loading branch information
priezz authored Dec 18, 2023
2 parents 1af5339 + 5c5f1b1 commit 24c92c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion freezegun/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def timestamp(self):
def now(cls, tz=None):
now = cls._time_to_freeze() or real_datetime.now()
if tz:
result = tz.fromutc(now.replace(tzinfo=tz)) + cls._tz_offset()
result = tz.fromutc(now.replace(tzinfo=tz))
else:
result = now + cls._tz_offset()
return datetime_to_fakedatetime(result)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_datetime_timezone_real():
@freeze_time("2012-01-14 2:00:00", tz_offset=-4)
def test_datetime_timezone_real_with_offset():
now = datetime.datetime.now(tz=GMT5())
assert now == datetime.datetime(2012, 1, 14, 3, tzinfo=GMT5())
assert now == datetime.datetime(2012, 1, 14, 7, tzinfo=GMT5())
assert now.utcoffset() == timedelta(0, 60 * 60 * 5)


Expand Down

0 comments on commit 24c92c6

Please sign in to comment.