pytz - pydoc - phpman

Look up a command

 

Markdown Format | JSON API | MCP Server Tool


pytz
NAME DESCRIPTION PACKAGE CONTENTS CLASSES FUNCTIONS DATA VERSION FILE
Help on package pytz:

NAME
    pytz

DESCRIPTION
    datetime.tzinfo timezone definitions generated from the
    Olson timezone database:

        ftp://elsie.nci.nih.gov/pub/tz*.tar.gz

    See the datetime section of the Python Library Reference for information
    on how to use these modules.

PACKAGE CONTENTS
    exceptions
    lazy
    reference
    tzfile
    tzinfo

CLASSES
    builtins.KeyError(builtins.LookupError)
        pytz.exceptions.UnknownTimeZoneError(builtins.KeyError, pytz.exceptions.Error)
    datetime.tzinfo(builtins.object)
        pytz.tzinfo.BaseTzInfo
    pytz.exceptions.Error(builtins.Exception)
        pytz.exceptions.InvalidTimeError
            pytz.exceptions.AmbiguousTimeError
            pytz.exceptions.NonExistentTimeError
        pytz.exceptions.UnknownTimeZoneError(builtins.KeyError, pytz.exceptions.Error)

    class AmbiguousTimeError(InvalidTimeError)
     |  Exception raised when attempting to create an ambiguous wallclock time.
     |
     |  At the end of a DST transition period, a particular wallclock time will
     |  occur twice (once before the clocks are set back, once after). Both
     |  possibilities may be correct, unless further information is supplied.
     |
     |  See DstTzInfo.normalize() for more info
     |
     |  Method resolution order:
     |      AmbiguousTimeError
     |      InvalidTimeError
     |      Error
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Data descriptors inherited from Error:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.Exception:
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.Exception:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class BaseTzInfo(datetime.tzinfo)
     |  Method resolution order:
     |      BaseTzInfo
     |      datetime.tzinfo
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __str__(self)
     |      Return str(self).
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  zone = None
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from datetime.tzinfo:
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      -> (cls, state)
     |
     |  dst(...)
     |      datetime -> DST offset as timedelta positive east of UTC.
     |
     |  fromutc(...)
     |      datetime in UTC -> datetime in local time.
     |
     |  tzname(...)
     |      datetime -> string name of time zone.
     |
     |  utcoffset(...)
     |      datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from datetime.tzinfo:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

    class InvalidTimeError(Error)
     |  Base class for invalid time exceptions.
     |
     |  Method resolution order:
     |      InvalidTimeError
     |      Error
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Data descriptors inherited from Error:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.Exception:
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.Exception:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class NonExistentTimeError(InvalidTimeError)
     |  Exception raised when attempting to create a wallclock time that
     |  cannot exist.
     |
     |  At the start of a DST transition period, the wallclock time jumps forward.
     |  The instants jumped over never occur.
     |
     |  Method resolution order:
     |      NonExistentTimeError
     |      InvalidTimeError
     |      Error
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Data descriptors inherited from Error:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.Exception:
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.Exception:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class UnknownTimeZoneError(builtins.KeyError, Error)
     |  Exception raised when pytz is passed an unknown timezone.
     |
     |  >>> isinstance(UnknownTimeZoneError(), LookupError)
     |  True
     |
     |  This class is actually a subclass of KeyError to provide backwards
     |  compatibility with code relying on the undocumented behavior of earlier
     |  pytz releases.
     |
     |  >>> isinstance(UnknownTimeZoneError(), KeyError)
     |  True
     |
     |  And also a subclass of pytz.exceptions.Error, as are other pytz
     |  exceptions.
     |
     |  >>> isinstance(UnknownTimeZoneError(), Error)
     |  True
     |
     |  Method resolution order:
     |      UnknownTimeZoneError
     |      builtins.KeyError
     |      builtins.LookupError
     |      Error
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.KeyError:
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.LookupError:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

FUNCTIONS
    FixedOffset(offset, _tzinfos={})
        return a fixed-offset timezone based off a number of minutes.

            >>> one = FixedOffset(-330)
            >>> one
            pytz.FixedOffset(-330)
            >>> str(one.utcoffset(datetime.datetime.now()))
            '-1 day, 18:30:00'
            >>> str(one.dst(datetime.datetime.now()))
            '0:00:00'

            >>> two = FixedOffset(1380)
            >>> two
            pytz.FixedOffset(1380)
            >>> str(two.utcoffset(datetime.datetime.now()))
            '23:00:00'
            >>> str(two.dst(datetime.datetime.now()))
            '0:00:00'

        The datetime.timedelta must be between the range of -1 and 1 day,
        non-inclusive.

            >>> FixedOffset(1440)
            Traceback (most recent call last):
            ...
            ValueError: ('absolute offset is too large', 1440)

            >>> FixedOffset(-1440)
            Traceback (most recent call last):
            ...
            ValueError: ('absolute offset is too large', -1440)

        An offset of 0 is special-cased to return UTC.

            >>> FixedOffset(0) is UTC
            True

        There should always be only one instance of a FixedOffset per timedelta.
        This should be true for multiple creation calls.

            >>> FixedOffset(-330) is one
            True
            >>> FixedOffset(1380) is two
            True

        It should also be true for pickling.

            >>> import pickle
            >>> pickle.loads(pickle.dumps(one)) is one
            True
            >>> pickle.loads(pickle.dumps(two)) is two
            True

    timezone(zone)
        Return a datetime.tzinfo implementation for the given timezone

        >>> from datetime import datetime, timedelta
        >>> utc = timezone('UTC')
        >>> eastern = timezone('US/Eastern')
        >>> eastern.zone
        'US/Eastern'
        >>> timezone(unicode('US/Eastern')) is eastern
        True
        >>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
        >>> loc_dt = utc_dt.astimezone(eastern)
        >>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
        >>> loc_dt.strftime(fmt)
        '2002-10-27 01:00:00 EST (-0500)'
        >>> (loc_dt - timedelta(minutes=10)).strftime(fmt)
        '2002-10-27 00:50:00 EST (-0500)'
        >>> eastern.normalize(loc_dt - timedelta(minutes=10)).strftime(fmt)
        '2002-10-27 01:50:00 EDT (-0400)'
        >>> (loc_dt + timedelta(minutes=10)).strftime(fmt)
        '2002-10-27 01:10:00 EST (-0500)'

        Raises UnknownTimeZoneError if passed an unknown zone.

        >>> try:
        ...     timezone('Asia/Shangri-La')
        ... except UnknownTimeZoneError:
        ...     print('Unknown')
        Unknown

        >>> try:
        ...     timezone(unicode('\N{TRADE MARK SIGN}'))
        ... except UnknownTimeZoneError:
        ...     print('Unknown')
        Unknown

DATA
    __all__ = ['timezone', 'utc', 'country_timezones', 'country_names', 'A...
    all_timezones = ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa...
    all_timezones_set = {'Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_A...
    common_timezones = ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ab...
    common_timezones_set = {'Africa/Abidjan', 'Africa/Accra', 'Africa/Addi...
    country_names = <pytz._CountryNameDict object>
    country_timezones = <pytz._CountryTimezoneDict object>
    utc = <UTC>

VERSION
    2022.1

FILE
    /usr/lib/python3/dist-packages/pytz/__init__.py



Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 TransitionalValid CSS!

^_back to top