Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eec4a5a

Browse files
committed
Remove pytz from dates.py
1 parent 5129b0b commit eec4a5a

1 file changed

Lines changed: 7 additions & 26 deletions

File tree

lib/matplotlib/dates.py

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Matplotlib 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:
@@ -46,19 +45,17 @@
4645
4746
All the Matplotlib date converters, tickers and formatters are timezone aware.
4847
If 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
5049
with the tz keyword argument to :func:`num2date`, :func:`.plot_date`, and any
5150
custom date tickers or locators you create.
52-
See `pytz <http://pythonhosted.org/pytz/>`_ for information on :mod:`pytz` and
53-
timezone handling.
5451
5552
A wide range of specific and general purpose date tick locators and
5653
formatters are provided in this module. See
5754
:mod:`matplotlib.ticker` for general information on tick locators
5855
and 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
6259
additional code to handle date ticking, making it easy to place ticks
6360
on any kinds of dates. See examples below.
6461
@@ -110,7 +107,7 @@
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
@@ -149,6 +146,7 @@
149146
SECONDLY)
150147
from dateutil.relativedelta import relativedelta
151148
import dateutil.parser
149+
import dateutil.tz
152150
import numpy as np
153151

154152
import matplotlib
@@ -175,23 +173,7 @@
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

197179
def _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

Comments
 (0)