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

Skip to content

Commit b17f5ae

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

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/matplotlib/dates.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,8 +1394,9 @@ def __init__(self, base=1, month=1, day=1, tz=None):
13941394
'minute': 0,
13951395
'second': 0,
13961396
}
1397-
# Note that tzinfo does not work with pytz timezones, so
1398-
# we need to set this here, and convert using astimezone
1397+
# Note that tzinfo does not work with pytz timezones, and
1398+
# astimezone doesn't work unless a datetime has timezone info (for
1399+
# py3.5). So the user should provide time-zone aware dates.
13991400

14001401
def __call__(self):
14011402
# if no data have been set, this will tank with a ValueError

lib/matplotlib/tests/test_dates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ def _create_auto_date_locator(date1, date2, tz):
576576
d1 = tz.localize(datetime.datetime(1997, 1, 1))
577577
for t_delta, expected in results:
578578
with rc_context({'_internal.classic_mode': False}):
579-
580579
d2 = d1 + t_delta
581580
locator = _create_auto_date_locator(d1, d2, tz)
582-
assert list(map(str, mdates.num2date(locator(), tz=tz))) == expected
581+
strings = list(map(str, mdates.num2date(locator(), tz=tz)))
582+
assert strings == expected
583583

584584

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

0 commit comments

Comments
 (0)
0