module documentation

This module offers timezone implementations subclassing the abstract :py:class:`datetime.tzinfo` type. There are classes to handle tzfile format files (usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, etc), TZ environment string (in all known formats), given ranges (with help from relative deltas), local machine timezone, fixed offset timezone, and UTC timezone.

Class tzfile This is a ``tzinfo`` subclass that allows one to use the ``tzfile(5)`` format timezone files to extract current and historical zone information.
Class tzical This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure as set out in `RFC 5545`_ Section 4.6.5 into one or more `tzinfo` objects.
Class tzlocal A :class:`tzinfo` subclass built around the ``time`` timezone functions.
Class tzoffset A simple class for representing a fixed offset from UTC.
Class tzrange The ``tzrange`` object is a time zone specified by a set of offsets and abbreviations, equivalent to the way the ``TZ`` variable can be specified in POSIX-like systems, but using Python delta objects to specify DST start, end and offsets.
Class tzstr ``tzstr`` objects are time zone objects specified by a time-zone string as it would be passed to a ``TZ`` variable on POSIX-style systems (see the `GNU C Library: TZ Variable`_ for more details).
Class tzutc This is a tzinfo object that represents the UTC time zone.
Function datetime_ambiguous Given a datetime and a time zone, determine whether or not a given datetime is ambiguous (i.e if there are two times differentiated only by their DST status).
Function datetime_exists Given a datetime and a time zone, determine whether or not a given datetime would fall in a gap.
Function resolve_imaginary Given a datetime that may be imaginary, return an existing datetime.
Constant EPOCH Undocumented
Constant EPOCHORDINAL Undocumented
Constant TZFILES Undocumented
Constant TZPATHS Undocumented
Constant UTC Undocumented
Constant ZERO Undocumented
Variable gettz Undocumented
Variable tzwin Undocumented
Variable tzwinlocal Undocumented
Class _nullcontext Class for wrapping contexts so that they are passed through in a with statement.
Class _ttinfo Undocumented
Class _tzfile Lightweight class for holding the relevant transition and time zone information read from binary tzfiles.
Class _tzicalvtz Undocumented
Class _tzicalvtzcomp Undocumented
Function __get_gettz Undocumented
Function _datetime_to_timestamp Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds since January 1, 1970, ignoring the time zone.
Function _get_supported_offset Undocumented
def datetime_ambiguous(dt, tz=None): (source)

Given a datetime and a time zone, determine whether or not a given datetime is ambiguous (i.e if there are two times differentiated only by their DST status). :param dt: A :class:`datetime.datetime` (whose time zone will be ignored if ``tz`` is provided.) :param tz: A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If ``None`` or not provided, the datetime's own time zone will be used. :return: Returns a boolean value whether or not the "wall time" is ambiguous in ``tz``. .. versionadded:: 2.6.0

def datetime_exists(dt, tz=None): (source)

Given a datetime and a time zone, determine whether or not a given datetime would fall in a gap. :param dt: A :class:`datetime.datetime` (whose time zone will be ignored if ``tz`` is provided.) :param tz: A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If ``None`` or not provided, the datetime's own time zone will be used. :return: Returns a boolean value whether or not the "wall time" exists in ``tz``. .. versionadded:: 2.7.0

def resolve_imaginary(dt): (source)

Given a datetime that may be imaginary, return an existing datetime. This function assumes that an imaginary datetime represents what the wall time would be in a zone had the offset transition not occurred, so it will always fall forward by the transition's change in offset. .. doctest:: >>> from dateutil import tz >>> from datetime import datetime >>> NYC = tz.gettz('America/New_York') >>> print(tz.resolve_imaginary(datetime(2017, 3, 12, 2, 30, tzinfo=NYC))) 2017-03-12 03:30:00-04:00 >>> KIR = tz.gettz('Pacific/Kiritimati') >>> print(tz.resolve_imaginary(datetime(1995, 1, 1, 12, 30, tzinfo=KIR))) 1995-01-02 12:30:00+14:00 As a note, :func:`datetime.astimezone` is guaranteed to produce a valid, existing datetime, so a round-trip to and from UTC is sufficient to get an extant datetime, however, this generally "falls back" to an earlier time rather than falling forward to the STD side (though no guarantees are made about this behavior). :param dt: A :class:`datetime.datetime` which may or may not exist. :return: Returns an existing :class:`datetime.datetime`. If ``dt`` was not imaginary, the datetime returned is guaranteed to be the same object passed to the function. .. versionadded:: 2.7.0

EPOCHORDINAL = (source)

Undocumented

Value
EPOCH.toordinal()
TZFILES: list[str] = (source)

Undocumented

Value
['/etc/localtime', 'localtime']
TZPATHS: list[str] = (source)

Undocumented

Value
['/usr/share/zoneinfo',
 '/usr/lib/zoneinfo',
 '/usr/share/lib/zoneinfo',
 '/etc/zoneinfo']

Undocumented

Value
tzutc()
ZERO = (source)

Undocumented

Value
datetime.timedelta(0)
gettz = (source)

Undocumented

tzwin = (source)

Undocumented

tzwinlocal = (source)

Undocumented

def __get_gettz(): (source)

Undocumented

def _datetime_to_timestamp(dt): (source)

Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds since January 1, 1970, ignoring the time zone.

def _get_supported_offset(second_offset): (source)

Undocumented