Skip to content

Commit

Permalink
Fix pendulum.parse('now', tz='...') ignoring the time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
pR0Ps committed Apr 5, 2023
1 parent f071ed3 commit 84d8c3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pendulum/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _parse(text: str, **options: t.Any) -> Date | DateTime | Time | Duration | I
"""
# Handling special cases
if text == "now":
return pendulum.now()
return pendulum.now(tz=options.get("tz", UTC))

parsed = base_parse(text, **options)

Expand Down
5 changes: 4 additions & 1 deletion tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ def test_parse_interval():


def test_parse_now():
dt = pendulum.parse("now")

pendulum.parse("now").timezone_name == "UTC"
pendulum.parse("now", tz="America/Los_Angeles").timezone_name == "America/Los_Angeles"

dt = pendulum.parse("now", tz="local")
assert dt.timezone_name == "America/Toronto"

mock_now = pendulum.yesterday()
Expand Down

0 comments on commit 84d8c3d

Please sign in to comment.