{
    "mode": "pydoc",
    "parameter": "pytz",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/pytz/json",
    "generated": "2026-06-02T15:03:56Z",
    "sections": {
        "NAME": {
            "content": "pytz\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "datetime.tzinfo timezone definitions generated from the\nOlson timezone database:\n\nftp://elsie.nci.nih.gov/pub/tz*.tar.gz\n\nSee the datetime section of the Python Library Reference for information\non how to use these modules.\n",
            "subsections": []
        },
        "PACKAGE CONTENTS": {
            "content": "exceptions\nlazy\nreference\ntzfile\ntzinfo\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.KeyError(builtins.LookupError)\npytz.exceptions.UnknownTimeZoneError(builtins.KeyError, pytz.exceptions.Error)\ndatetime.tzinfo(builtins.object)\npytz.tzinfo.BaseTzInfo\npytz.exceptions.Error(builtins.Exception)\npytz.exceptions.InvalidTimeError\npytz.exceptions.AmbiguousTimeError\npytz.exceptions.NonExistentTimeError\npytz.exceptions.UnknownTimeZoneError(builtins.KeyError, pytz.exceptions.Error)\n",
            "subsections": [
                {
                    "name": "class AmbiguousTimeError",
                    "content": "|  Exception raised when attempting to create an ambiguous wallclock time.\n|\n|  At the end of a DST transition period, a particular wallclock time will\n|  occur twice (once before the clocks are set back, once after). Both\n|  possibilities may be correct, unless further information is supplied.\n|\n|  See DstTzInfo.normalize() for more info\n|\n|  Method resolution order:\n|      AmbiguousTimeError\n|      InvalidTimeError\n|      Error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from Error:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class BaseTzInfo",
                    "content": "|  Method resolution order:\n|      BaseTzInfo\n|      datetime.tzinfo\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  str(self)\n|      Return str(self).\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  zone = None\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from datetime.tzinfo:\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      -> (cls, state)\n|\n|  dst(...)\n|      datetime -> DST offset as timedelta positive east of UTC.\n|\n|  fromutc(...)\n|      datetime in UTC -> datetime in local time.\n|\n|  tzname(...)\n|      datetime -> string name of time zone.\n|\n|  utcoffset(...)\n|      datetime -> timedelta showing offset from UTC, negative values indicating West of UTC\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from datetime.tzinfo:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n"
                },
                {
                    "name": "class InvalidTimeError",
                    "content": "|  Base class for invalid time exceptions.\n|\n|  Method resolution order:\n|      InvalidTimeError\n|      Error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from Error:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class NonExistentTimeError",
                    "content": "|  Exception raised when attempting to create a wallclock time that\n|  cannot exist.\n|\n|  At the start of a DST transition period, the wallclock time jumps forward.\n|  The instants jumped over never occur.\n|\n|  Method resolution order:\n|      NonExistentTimeError\n|      InvalidTimeError\n|      Error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from Error:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class UnknownTimeZoneError",
                    "content": "|  Exception raised when pytz is passed an unknown timezone.\n|\n|  >>> isinstance(UnknownTimeZoneError(), LookupError)\n|  True\n|\n|  This class is actually a subclass of KeyError to provide backwards\n|  compatibility with code relying on the undocumented behavior of earlier\n|  pytz releases.\n|\n|  >>> isinstance(UnknownTimeZoneError(), KeyError)\n|  True\n|\n|  And also a subclass of pytz.exceptions.Error, as are other pytz\n|  exceptions.\n|\n|  >>> isinstance(UnknownTimeZoneError(), Error)\n|  True\n|\n|  Method resolution order:\n|      UnknownTimeZoneError\n|      builtins.KeyError\n|      builtins.LookupError\n|      Error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.KeyError:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.LookupError:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "FixedOffset(offset, tzinfos={})\nreturn a fixed-offset timezone based off a number of minutes.\n\n>>> one = FixedOffset(-330)\n>>> one\npytz.FixedOffset(-330)\n>>> str(one.utcoffset(datetime.datetime.now()))\n'-1 day, 18:30:00'\n>>> str(one.dst(datetime.datetime.now()))\n'0:00:00'\n\n>>> two = FixedOffset(1380)\n>>> two\npytz.FixedOffset(1380)\n>>> str(two.utcoffset(datetime.datetime.now()))\n'23:00:00'\n>>> str(two.dst(datetime.datetime.now()))\n'0:00:00'\n\nThe datetime.timedelta must be between the range of -1 and 1 day,\nnon-inclusive.\n\n>>> FixedOffset(1440)\nTraceback (most recent call last):\n...\nValueError: ('absolute offset is too large', 1440)\n\n>>> FixedOffset(-1440)\nTraceback (most recent call last):\n...\nValueError: ('absolute offset is too large', -1440)\n\nAn offset of 0 is special-cased to return UTC.\n\n>>> FixedOffset(0) is UTC\nTrue\n\nThere should always be only one instance of a FixedOffset per timedelta.\nThis should be true for multiple creation calls.\n\n>>> FixedOffset(-330) is one\nTrue\n>>> FixedOffset(1380) is two\nTrue\n\nIt should also be true for pickling.\n\n>>> import pickle\n>>> pickle.loads(pickle.dumps(one)) is one\nTrue\n>>> pickle.loads(pickle.dumps(two)) is two\nTrue\n",
            "subsections": [
                {
                    "name": "timezone",
                    "content": "Return a datetime.tzinfo implementation for the given timezone\n\n>>> from datetime import datetime, timedelta\n>>> utc = timezone('UTC')\n>>> eastern = timezone('US/Eastern')\n>>> eastern.zone\n'US/Eastern'\n>>> timezone(unicode('US/Eastern')) is eastern\nTrue\n>>> utcdt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)\n>>> locdt = utcdt.astimezone(eastern)\n>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'\n>>> locdt.strftime(fmt)\n'2002-10-27 01:00:00 EST (-0500)'\n>>> (locdt - timedelta(minutes=10)).strftime(fmt)\n'2002-10-27 00:50:00 EST (-0500)'\n>>> eastern.normalize(locdt - timedelta(minutes=10)).strftime(fmt)\n'2002-10-27 01:50:00 EDT (-0400)'\n>>> (locdt + timedelta(minutes=10)).strftime(fmt)\n'2002-10-27 01:10:00 EST (-0500)'\n\nRaises UnknownTimeZoneError if passed an unknown zone.\n\n>>> try:\n...     timezone('Asia/Shangri-La')\n... except UnknownTimeZoneError:\n...     print('Unknown')\nUnknown\n\n>>> try:\n...     timezone(unicode('\\N{TRADE MARK SIGN}'))\n... except UnknownTimeZoneError:\n...     print('Unknown')\nUnknown\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['timezone', 'utc', 'countrytimezones', 'countrynames', 'A...\nalltimezones = ['Africa/Abidjan', 'Africa/Accra', 'Africa/AddisAbaba...\nalltimezonesset = {'Africa/Abidjan', 'Africa/Accra', 'Africa/AddisA...\ncommontimezones = ['Africa/Abidjan', 'Africa/Accra', 'Africa/AddisAb...\ncommontimezonesset = {'Africa/Abidjan', 'Africa/Accra', 'Africa/Addi...\ncountrynames = <pytz.CountryNameDict object>\ncountrytimezones = <pytz.CountryTimezoneDict object>\nutc = <UTC>\n",
            "subsections": []
        },
        "VERSION": {
            "content": "2022.1\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3/dist-packages/pytz/init.py\n\n",
            "subsections": []
        }
    },
    "summary": "pytz",
    "flags": [],
    "examples": [],
    "see_also": []
}