Skip to content

Commit 84d8c3d

Browse files
committed
Fix pendulum.parse('now', tz='...') ignoring the time zone
1 parent f071ed3 commit 84d8c3d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pendulum/parser.py

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

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

tests/test_parsing.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ def test_parse_interval():
125125

126126

127127
def test_parse_now():
128-
dt = pendulum.parse("now")
129128

129+
pendulum.parse("now").timezone_name == "UTC"
130+
pendulum.parse("now", tz="America/Los_Angeles").timezone_name == "America/Los_Angeles"
131+
132+
dt = pendulum.parse("now", tz="local")
130133
assert dt.timezone_name == "America/Toronto"
131134

132135
mock_now = pendulum.yesterday()

0 commit comments

Comments
 (0)