Skip to content

Commit 3313f1b

Browse files
committed
Fix pendulum.parse('now', tz='...') ignoring the time zone
1 parent 3e3fec6 commit 3313f1b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/pendulum/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _parse(text: str, **options: t.Any) -> Date | DateTime | Time | Duration | I
3838
"""
3939
# Handling special cases
4040
if text == "now":
41-
return pendulum.now()
41+
return pendulum.now(tz=options.get("tz", UTC))
4242

4343
parsed = base_parse(text, **options)
4444

tests/test_parsing.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,13 @@ def test_parse_interval() -> None:
128128

129129

130130
def test_parse_now() -> None:
131-
dt = pendulum.parse("now")
131+
assert pendulum.parse("now").timezone_name == "UTC"
132+
assert (
133+
pendulum.parse("now", tz="America/Los_Angeles").timezone_name
134+
== "America/Los_Angeles"
135+
)
132136

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

135140
mock_now = pendulum.yesterday()

0 commit comments

Comments
 (0)