8000 FIX: properly set tz for YearLocator · matplotlib/matplotlib@5736155 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5736155

Browse files
committed
FIX: properly set tz for YearLocator
1 parent 85afb2a commit 5736155

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/matplotlib/tests/test_dates.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from matplotlib.cbook import MatplotlibDeprecationWarning
1313
import matplotlib.dates as mdates
1414
import matplotlib.ticker as mticker
15+
from matplotlib import rc_context
1516

1617

1718
def __has_pytz():
@@ -572,11 +573,13 @@ def _create_auto_date_locator(date1, date2, tz):
572573
)
573574

574575
tz = pytz.timezone('US/Pacific')
575-
d1 = datetime.datetime(1997, 1, 1).astimezone(tz)
576+
d1 = tz.localize(datetime.datetime(1997, 1, 1))
576577
for t_delta, expected in results:
577-
d2 = d1 + t_delta
578-
locator = _create_auto_date_locator(d1, d2, tz)
579-
assert list(map(str, mdates.num2date(locator(), tz=tz))) == expected
578+
with rc_context({'_internal.classic_mode': False}):
579+
580+
d2 = d1 + t_delta
581+
locator = _create_auto_date_locator(d1, d2, tz)
582+
assert list(map(str, mdates.num2date(locator(), tz=tz))) == expected
580583

581584

582585
@image_comparison(baseline_images=['date_inverted_limit'],

0 commit comments

Comments
 (0)
0