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 Jan 17, 2024
1 parent 3e3fec6 commit 6c8a5cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pendulum/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 @@ -128,8 +128,11 @@ def test_parse_interval() -> None:


def test_parse_now() -> None:
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 6c8a5cc

Please sign in to comment.