11"""
22Matplotlib provides sophisticated date plotting capabilities, standing on the
3- shoulders of python :mod:`datetime` and the add-on module dateutil_.
3+ shoulders of python :mod:`datetime`, :mod:`zoneinfo`, and the add-on module dateutil_.
44
55By default, Matplotlib uses the units machinery described in
66`~matplotlib.units` to convert `datetime.datetime`, and `numpy.datetime64`
8787string. If you want to use a different timezone, pass the *tz* keyword
8888argument of `num2date` to any date tick locators or formatters you create. This
8989can be either a `datetime.tzinfo` instance or a string with the timezone name
90- that can be parsed by `~dateutil.tz.gettz `.
90+ that can be parsed by `~zoneinfo.ZoneInfo `.
9191
9292A wide range of specific and general purpose date tick locators and
9393formatters are provided in this module. See
177177import functools
178178import logging
179179import re
180+ import zoneinfo
180181
181182from dateutil .rrule import (rrule , MO , TU , WE , TH , FR , SA , SU , YEARLY ,
182183 MONTHLY , WEEKLY , DAILY , HOURLY , MINUTELY ,
183184 SECONDLY )
184185from dateutil .relativedelta import relativedelta
185186import dateutil .parser
186- import dateutil .tz
187187import numpy as np
188188
189189import matplotlib as mpl
@@ -214,10 +214,10 @@ def _get_tzinfo(tz=None):
214214 if tz == 'UTC' :
215215 return UTC
216216 if isinstance (tz , str ):
217- tzinfo = dateutil . tz . gettz (tz )
217+ tzinfo = zoneinfo . ZoneInfo (tz )
218218 if tzinfo is None :
219219 raise ValueError (f"{ tz } is not a valid timezone as parsed by"
220- " dateutil.tz.gettz ." )
220+ " zoneinfo.ZoneInfo ." )
221221 return tzinfo
222222 if isinstance (tz , datetime .tzinfo ):
223223 return tz
@@ -352,7 +352,7 @@ def _from_ordinalf(x, tz=None):
352352 dt = dt .tolist ()
353353
354354 # datetime64 is always UTC:
355- dt = dt .replace (tzinfo = dateutil . tz . gettz ( 'UTC' ) )
355+ dt = dt .replace (tzinfo = datetime . timezone . utc )
356356 # but maybe we are working in a different timezone so move.
357357 dt = dt .astimezone (tz )
358358 # fix round off errors
@@ -463,7 +463,7 @@ def num2date(x, tz=None):
463463 since the epoch. See `.get_epoch` for the
464464 epoch, which can be changed by :rc:`date.epoch` or `.set_epoch`.
465465 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
466- Timezone of *x*. If a string, *tz* is passed to `dateutil.tz `.
466+ Timezone of *x*. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
467467
468468 Returns
469469 -------
@@ -575,7 +575,7 @@ def __init__(self, fmt, tz=None, *, usetex=None):
575575 fmt : str
576576 `~datetime.datetime.strftime` format string
577577 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
578- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
578+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
579579 usetex : bool, default: :rc:`text.usetex`
580580 To enable/disable the use of TeX's math mode for rendering the
581581 results of the formatter.
@@ -888,7 +888,7 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d', *,
888888 Locator that this axis is using.
889889
890890 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
891- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
891+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
892892
893893 defaultfmt : str
894894 The default format to use if none of the values in ``self.scaled``
@@ -1075,7 +1075,7 @@ def __init__(self, tz=None):
10751075 Parameters
10761076 ----------
10771077 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1078- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1078+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
10791079 """
10801080 self .tz = _get_tzinfo (tz )
10811081
@@ -1086,7 +1086,7 @@ def set_tzinfo(self, tz):
10861086 Parameters
10871087 ----------
10881088 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1089- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1089+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
10901090 """
10911091 self .tz = _get_tzinfo (tz )
10921092
@@ -1259,7 +1259,7 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
12591259 Parameters
12601260 ----------
12611261 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1262- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1262+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
12631263 minticks : int
12641264 The minimum number of ticks desired; controls whether ticks occur
12651265 yearly, monthly, etc.
@@ -1470,7 +1470,7 @@ def __init__(self, base=1, month=1, day=1, tz=None):
14701470 day : int, default: 1
14711471 The day on which to place the ticks.
14721472 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1473- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1473+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
14741474 """
14751475 rule = rrulewrapper (YEARLY , interval = base , bymonth = month ,
14761476 bymonthday = day , ** self .hms0d )
@@ -1513,7 +1513,7 @@ def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None):
15131513 The interval between each iteration. For example, if
15141514 ``interval=2``, mark every second occurrence.
15151515 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1516- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1516+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
15171517 """
15181518 if bymonth is None :
15191519 bymonth = range (1 , 13 )
@@ -1545,7 +1545,7 @@ def __init__(self, byweekday=1, interval=1, tz=None):
15451545 The interval between each iteration. For example, if
15461546 ``interval=2``, mark every second occurrence.
15471547 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1548- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1548+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
15491549 """
15501550 rule = rrulewrapper (DAILY , byweekday = byweekday ,
15511551 interval = interval , ** self .hms0d )
@@ -1568,7 +1568,7 @@ def __init__(self, bymonthday=None, interval=1, tz=None):
15681568 The interval between each iteration. For example, if
15691569 ``interval=2``, mark every second occurrence.
15701570 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1571- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1571+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
15721572 """
15731573 if interval != int (interval ) or interval < 1 :
15741574 raise ValueError ("interval must be an integer greater than 0" )
@@ -1595,7 +1595,7 @@ def __init__(self, byhour=None, interval=1, tz=None):
15951595 The interval between each iteration. For example, if
15961596 ``interval=2``, mark every second occurrence.
15971597 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1598- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1598+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
15991599 """
16001600 if byhour is None :
16011601 byhour = range (24 )
@@ -1620,7 +1620,7 @@ def __init__(self, byminute=None, interval=1, tz=None):
16201620 The interval between each iteration. For example, if
16211621 ``interval=2``, mark every second occurrence.
16221622 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1623- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1623+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
16241624 """
16251625 if byminute is None :
16261626 byminute = range (60 )
@@ -1645,7 +1645,7 @@ def __init__(self, bysecond=None, interval=1, tz=None):
16451645 The interval between each iteration. For example, if
16461646 ``interval=2``, mark every second occurrence.
16471647 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1648- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1648+ Ticks timezone. If a string, *tz* is passed to `~zoneinfo.ZoneInfo `.
16491649 """
16501650 if bysecond is None :
16511651 bysecond = range (60 )
@@ -1684,7 +1684,7 @@ def __init__(self, interval=1, tz=None):
16841684 The interval between each iteration. For example, if
16851685 ``interval=2``, mark every second occurrence.
16861686 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1687- Ticks timezone. If a string, *tz* is passed to `dateutil.tz `.
1687+ Ticks timezone. If a string, *tz* is passed to `ZoneInfo `.
16881688 """
16891689 super ().__init__ (tz = tz )
16901690 self ._interval = interval
0 commit comments