11"""
22Matplotlib provides sophisticated date plotting capabilities, standing on the
3- shoulders of python :mod:`datetime`, the add-on modules :mod:`pytz` and
4- :mod:`dateutil`.
3+ shoulders of python :mod:`datetime` and the add-on module :mod:`dateutil`.
54
65
76.. _date-format:
4645
4746All the Matplotlib date converters, tickers and formatters are timezone aware.
4847If no explicit timezone is provided, the rcParam ``timezone`` is assumend. If
49- you want to use a custom time zone, pass a :class:`pytz.timezone ` instance
48+ you want to use a custom time zone, pass a :class:`datetime.tzinfo ` instance
5049with the tz keyword argument to :func:`num2date`, :func:`.plot_date`, and any
5150custom date tickers or locators you create.
52- See `pytz <http://pythonhosted.org/pytz/>`_ for information on :mod:`pytz` and
53- timezone handling.
5451
5552A wide range of specific and general purpose date tick locators and
5653formatters are provided in this module. See
5754:mod:`matplotlib.ticker` for general information on tick locators
5855and formatters. These are described below.
5956
6057
61- The `dateutil module <https://dateutil.readthedocs.io/en/stable/ >`_ provides
58+ The `dateutil module <https://dateutil.readthedocs.io>`_ provides
6259additional code to handle date ticking, making it easy to place ticks
6360on any kinds of dates. See examples below.
6461
110107 :class:`matplotlib.dates.rrulewrapper`. The
111108 :class:`rrulewrapper` is a simple wrapper around a
112109 :class:`dateutil.rrule` (`dateutil
113- <https://dateutil.readthedocs.io/en/stable/ >`_) which allow almost
110+ <https://dateutil.readthedocs.io>`_) which allow almost
114111 arbitrary date tick specifications. See `rrule example
115112 <../gallery/ticks_and_spines/date_demo_rrule.html>`_.
116113
149146 SECONDLY )
150147from dateutil .relativedelta import relativedelta
151148import dateutil .parser
149+ import dateutil .tz
152150import numpy as np
153151
154152import matplotlib
175173_log = logging .getLogger (__name__ )
176174
177175
178- # Make a simple UTC instance so we don't always have to import
179- # pytz. From the python datetime library docs:
180-
181- class _UTC (datetime .tzinfo ):
182- """UTC"""
183-
184- def utcoffset (self , dt ):
185- return datetime .timedelta (0 )
186-
187- def tzname (self , dt ):
188- return "UTC"
189-
190- def dst (self , dt ):
191- return datetime .timedelta (0 )
192-
193-
194- UTC = _UTC ()
176+ UTC = datetime .timezone .utc
195177
196178
197179def _get_rc_timezone ():
@@ -201,8 +183,7 @@ def _get_rc_timezone():
201183 s = matplotlib .rcParams ['timezone' ]
202184 if s == 'UTC' :
203185 return UTC
204- import pytz
205- return pytz .timezone (s )
186+ return dateutil .tz .gettz (s )
206187
207188
208189"""
0 commit comments