python-dateutil API Reference
Full documentation for python-dateutil (2.9.0.post0)
python-dateutil.easter
Python Library Documentation: module dateutil.easter in dateutil
NAME
dateutil.easter
DESCRIPTION
This module offers a generic Easter computing method for any given year, using
Western, Orthodox or Julian algorithms.
FUNCTIONS
easter(year, method=3)
This method was ported from the work done by GM Arts,
on top of the algorithm by Claus Tondering, which was
based in part on the algorithm of Ouding (1940), as
quoted in "Explanatory Supplement to the Astronomical
Almanac", P. Kenneth Seidelmann, editor.
This algorithm implements three different Easter
calculation methods:
1. Original calculation in Julian calendar, valid in
dates after 326 AD
2. Original method, with date converted to Gregorian
calendar, valid in years 1583 to 4099
3. Revised method, in Gregorian calendar, valid in
years 1583 to 4099 as well
These methods are represented by the constants:
* ``EASTER_JULIAN = 1``
* ``EASTER_ORTHODOX = 2``
* ``EASTER_WESTERN = 3``
The default method is method 3.
More about the algorithm may be found at:
`GM Arts: Easter Algorithms <http://www.gmarts.org/index.php?go=415>`_
and
`The Calendar FAQ: Easter <https://www.tondering.dk/claus/cal/easter.php>`_
DATA
EASTER_JULIAN = 1
EASTER_ORTHODOX = 2
EASTER_WESTERN = 3
__all__ = ['easter', 'EASTER_JULIAN', 'EASTER_ORTHODOX', 'EASTER_WESTE...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\easter.py
python-dateutil.parser
Python Library Documentation: package dateutil.parser in dateutil
NAME
dateutil.parser
DESCRIPTION
This module offers a generic date/time string parser which is able to parse
most known formats to represent a date and/or time.
This module attempts to be forgiving with regards to unlikely input formats,
returning a datetime object even for dates which are ambiguous. If an element
of a date/time stamp is omitted, the following rules are applied:
- If AM or PM is left unspecified, a 24-hour clock is assumed, however, an hour
on a 12-hour clock (``0 <= hour <= 12``) *must* be specified if AM or PM is
specified.
- If a time zone is omitted, a timezone-naive datetime is returned.
If any other elements are missing, they are taken from the
:class:`datetime.datetime` object passed to the parameter ``default``. If this
results in a day number exceeding the valid number of days per month, the
value falls back to the end of the month.
Additional resources about date/time string formats can be found below:
- `A summary of the international standard date and time notation
<https://www.cl.cam.ac.uk/~mgk25/iso-time.html>`_
- `W3C Date and Time Formats <https://www.w3.org/TR/NOTE-datetime>`_
- `Time Formats (Planetary Rings Node) <https://pds-rings.seti.org:443/tools/time_formats.html>`_
- `CPAN ParseDate module
<https://metacpan.org/pod/release/MUIR/Time-modules-2013.0912/lib/Time/ParseDate.pm>`_
- `Java SimpleDateFormat Class
<https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html>`_
PACKAGE CONTENTS
_parser
isoparser
CLASSES
builtins.RuntimeWarning(builtins.Warning)
dateutil.parser._parser.UnknownTimezoneWarning
builtins.ValueError(builtins.Exception)
dateutil.parser._parser.ParserError
builtins.object
dateutil.parser._parser.parser
dateutil.parser._parser.parserinfo
dateutil.parser.isoparser.isoparser
class ParserError(builtins.ValueError)
| Exception subclass used for any failure to parse a datetime string.
|
| This is a subclass of :py:exc:`ValueError`, and should be raised any time
| earlier versions of ``dateutil`` would have raised ``ValueError``.
|
| .. versionadded:: 2.8.1
|
| Method resolution order:
| ParserError
| builtins.ValueError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __repr__(self)
| Return repr(self).
|
| __str__(self)
| Return str(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.ValueError:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.ValueError:
|
| __new__(*args, **kwargs) class method of builtins.ValueError
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| 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 UnknownTimezoneWarning(builtins.RuntimeWarning)
| Raised when the parser finds a timezone it cannot parse into a tzinfo.
|
| .. versionadded:: 2.7.0
|
| Method resolution order:
| UnknownTimezoneWarning
| builtins.RuntimeWarning
| builtins.Warning
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.RuntimeWarning:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.RuntimeWarning:
|
| __new__(*args, **kwargs) class method of builtins.RuntimeWarning
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| 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 isoparser(builtins.object)
| isoparser(sep=None)
|
| Methods defined here:
|
| __init__(self, sep=None)
| :param sep:
| A single character that separates date and time portions. If
| ``None``, the parser will accept any single character.
| For strict ISO-8601 adherence, pass ``'T'``.
|
| isoparse(self, dt_str)
| Parse an ISO-8601 datetime string into a :class:`datetime.datetime`.
|
| An ISO-8601 datetime string consists of a date portion, followed
| optionally by a time portion - the date and time portions are separated
| by a single character separator, which is ``T`` in the official
| standard. Incomplete date formats (such as ``YYYY-MM``) may *not* be
| combined with a time portion.
|
| Supported date formats are:
|
| Common:
|
| - ``YYYY``
| - ``YYYY-MM``
| - ``YYYY-MM-DD`` or ``YYYYMMDD``
|
| Uncommon:
|
| - ``YYYY-Www`` or ``YYYYWww`` - ISO week (day defaults to 0)
| - ``YYYY-Www-D`` or ``YYYYWwwD`` - ISO week and day
|
| The ISO week and day numbering follows the same logic as
| :func:`datetime.date.isocalendar`.
|
| Supported time formats are:
|
| - ``hh``
| - ``hh:mm`` or ``hhmm``
| - ``hh:mm:ss`` or ``hhmmss``
| - ``hh:mm:ss.ssssss`` (Up to 6 sub-second digits)
|
| Midnight is a special case for `hh`, as the standard supports both
| 00:00 and 24:00 as a representation. The decimal separator can be
| either a dot or a comma.
|
|
| .. caution::
|
| Support for fractional components other than seconds is part of the
| ISO-8601 standard, but is not currently implemented in this parser.
|
| Supported time zone offset formats are:
|
| - `Z` (UTC)
| - `±HH:MM`
| - `±HHMM`
| - `±HH`
|
| Offsets will be represented as :class:`dateutil.tz.tzoffset` objects,
| with the exception of UTC, which will be represented as
| :class:`dateutil.tz.tzutc`. Time zone offsets equivalent to UTC (such
| as `+00:00`) will also be represented as :class:`dateutil.tz.tzutc`.
|
| :param dt_str:
| A string or stream containing only an ISO-8601 datetime string
|
| :return:
| Returns a :class:`datetime.datetime` representing the string.
| Unspecified components default to their lowest value.
|
| .. warning::
|
| As of version 2.7.0, the strictness of the parser should not be
| considered a stable part of the contract. Any valid ISO-8601 string
| that parses correctly with the default settings will continue to
| parse correctly in future versions, but invalid strings that
| currently fail (e.g. ``2017-01-01T00:00+00:00:00``) are not
| guaranteed to continue failing in future versions if they encode
| a valid date.
|
| .. versionadded:: 2.7.0
|
| parse_isodate(self, datestr)
| Parse the date portion of an ISO string.
|
| :param datestr:
| The string portion of an ISO string, without a separator
|
| :return:
| Returns a :class:`datetime.date` object
|
| parse_isotime(self, timestr)
| Parse the time portion of an ISO string.
|
| :param timestr:
| The time portion of an ISO string, without a separator
|
| :return:
| Returns a :class:`datetime.time` object
|
| parse_tzstr(self, tzstr, zero_as_utc=True)
| Parse a valid ISO time zone string.
|
| See :func:`isoparser.isoparse` for details on supported formats.
|
| :param tzstr:
| A string representing an ISO time zone offset
|
| :param zero_as_utc:
| Whether to return :class:`dateutil.tz.tzutc` for zero-offset zones
|
| :return:
| Returns :class:`dateutil.tz.tzoffset` for offsets and
| :class:`dateutil.tz.tzutc` for ``Z`` and (if ``zero_as_utc`` is
| specified) offsets equivalent to UTC.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class parser(builtins.object)
| parser(info=None)
|
| Methods defined here:
|
| __init__(self, info=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| parse(self, timestr, default=None, ignoretz=False, tzinfos=None, **kwargs)
| Parse the date/time string into a :class:`datetime.datetime` object.
|
| :param timestr:
| Any date/time string using the supported formats.
|
| :param default:
| The default datetime object, if this is a datetime object and not
| ``None``, elements specified in ``timestr`` replace elements in the
| default object.
|
| :param ignoretz:
| If set ``True``, time zones in parsed strings are ignored and a
| naive :class:`datetime.datetime` object is returned.
|
| :param tzinfos:
| Additional time zone names / aliases which may be present in the
| string. This argument maps time zone names (and optionally offsets
| from those time zones) to time zones. This parameter can be a
| dictionary with timezone aliases mapping time zone names to time
| zones or a function taking two parameters (``tzname`` and
| ``tzoffset``) and returning a time zone.
|
| The timezones to which the names are mapped can be an integer
| offset from UTC in seconds or a :class:`tzinfo` object.
|
| .. doctest::
| :options: +NORMALIZE_WHITESPACE
|
| >>> from dateutil.parser import parse
| >>> from dateutil.tz import gettz
| >>> tzinfos = {"BRST": -7200, "CST": gettz("America/Chicago")}
| >>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos)
| datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -7200))
| >>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos)
| datetime.datetime(2012, 1, 19, 17, 21,
| tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago'))
|
| This parameter is ignored if ``ignoretz`` is set.
|
| :param \*\*kwargs:
| Keyword arguments as passed to ``_parse()``.
|
| :return:
| Returns a :class:`datetime.datetime` object or, if the
| ``fuzzy_with_tokens`` option is ``True``, returns a tuple, the
| first element being a :class:`datetime.datetime` object, the second
| a tuple containing the fuzzy tokens.
|
| :raises ParserError:
| Raised for invalid or unknown string format, if the provided
| :class:`tzinfo` is not in a valid format, or if an invalid date
| would be created.
|
| :raises TypeError:
| Raised for non-string or character stream input.
|
| :raises OverflowError:
| Raised if the parsed date exceeds the largest valid C integer on
| your system.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class parserinfo(builtins.object)
| parserinfo(dayfirst=False, yearfirst=False)
|
| Class which handles what inputs are accepted. Subclass this to customize
| the language and acceptable values for each parameter.
|
| :param dayfirst:
| Whether to interpret the first value in an ambiguous 3-integer date
| (e.g. 01/05/09) as the day (``True``) or month (``False``). If
| ``yearfirst`` is set to ``True``, this distinguishes between YDM
| and YMD. Default is ``False``.
|
| :param yearfirst:
| Whether to interpret the first value in an ambiguous 3-integer date
| (e.g. 01/05/09) as the year. If ``True``, the first number is taken
| to be the year, otherwise the last number is taken to be the year.
| Default is ``False``.
|
| Methods defined here:
|
| __init__(self, dayfirst=False, yearfirst=False)
| Initialize self. See help(type(self)) for accurate signature.
|
| ampm(self, name)
|
| convertyear(self, year, century_specified=False)
| Converts two-digit years to year within [-50, 49]
| range of self._year (current local time)
|
| hms(self, name)
|
| jump(self, name)
|
| month(self, name)
|
| pertain(self, name)
|
| tzoffset(self, name)
|
| utczone(self, name)
|
| validate(self, res)
|
| weekday(self, name)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| AMPM = [('am', 'a'), ('pm', 'p')]
|
| HMS = [('h', 'hour', 'hours'), ('m', 'minute', 'minutes'), ('s', 'seco...
|
| JUMP = [' ', '.', ',', ';', '-', '/', "'", 'at', 'on', 'and', 'ad', 'm...
|
| MONTHS = [('Jan', 'January'), ('Feb', 'February'), ('Mar', 'March'), (...
|
| PERTAIN = ['of']
|
| TZOFFSET = {}
|
| UTCZONE = ['UTC', 'GMT', 'Z', 'z']
|
| WEEKDAYS = [('Mon', 'Monday'), ('Tue', 'Tuesday'), ('Wed', 'Wednesday'...
FUNCTIONS
isoparse(dt_str) method of dateutil.parser.isoparser.isoparser instance
Parse an ISO-8601 datetime string into a :class:`datetime.datetime`.
An ISO-8601 datetime string consists of a date portion, followed
optionally by a time portion - the date and time portions are separated
by a single character separator, which is ``T`` in the official
standard. Incomplete date formats (such as ``YYYY-MM``) may *not* be
combined with a time portion.
Supported date formats are:
Common:
- ``YYYY``
- ``YYYY-MM``
- ``YYYY-MM-DD`` or ``YYYYMMDD``
Uncommon:
- ``YYYY-Www`` or ``YYYYWww`` - ISO week (day defaults to 0)
- ``YYYY-Www-D`` or ``YYYYWwwD`` - ISO week and day
The ISO week and day numbering follows the same logic as
:func:`datetime.date.isocalendar`.
Supported time formats are:
- ``hh``
- ``hh:mm`` or ``hhmm``
- ``hh:mm:ss`` or ``hhmmss``
- ``hh:mm:ss.ssssss`` (Up to 6 sub-second digits)
Midnight is a special case for `hh`, as the standard supports both
00:00 and 24:00 as a representation. The decimal separator can be
either a dot or a comma.
.. caution::
Support for fractional components other than seconds is part of the
ISO-8601 standard, but is not currently implemented in this parser.
Supported time zone offset formats are:
- `Z` (UTC)
- `±HH:MM`
- `±HHMM`
- `±HH`
Offsets will be represented as :class:`dateutil.tz.tzoffset` objects,
with the exception of UTC, which will be represented as
:class:`dateutil.tz.tzutc`. Time zone offsets equivalent to UTC (such
as `+00:00`) will also be represented as :class:`dateutil.tz.tzutc`.
:param dt_str:
A string or stream containing only an ISO-8601 datetime string
:return:
Returns a :class:`datetime.datetime` representing the string.
Unspecified components default to their lowest value.
.. warning::
As of version 2.7.0, the strictness of the parser should not be
considered a stable part of the contract. Any valid ISO-8601 string
that parses correctly with the default settings will continue to
parse correctly in future versions, but invalid strings that
currently fail (e.g. ``2017-01-01T00:00+00:00:00``) are not
guaranteed to continue failing in future versions if they encode
a valid date.
.. versionadded:: 2.7.0
parse(timestr, parserinfo=None, **kwargs)
Parse a string in one of the supported formats, using the
``parserinfo`` parameters.
:param timestr:
A string containing a date/time stamp.
:param parserinfo:
A :class:`parserinfo` object containing parameters for the parser.
If ``None``, the default arguments to the :class:`parserinfo`
constructor are used.
The ``**kwargs`` parameter takes the following keyword arguments:
:param default:
The default datetime object, if this is a datetime object and not
``None``, elements specified in ``timestr`` replace elements in the
default object.
:param ignoretz:
If set ``True``, time zones in parsed strings are ignored and a naive
:class:`datetime` object is returned.
:param tzinfos:
Additional time zone names / aliases which may be present in the
string. This argument maps time zone names (and optionally offsets
from those time zones) to time zones. This parameter can be a
dictionary with timezone aliases mapping time zone names to time
zones or a function taking two parameters (``tzname`` and
``tzoffset``) and returning a time zone.
The timezones to which the names are mapped can be an integer
offset from UTC in seconds or a :class:`tzinfo` object.
.. doctest::
:options: +NORMALIZE_WHITESPACE
>>> from dateutil.parser import parse
>>> from dateutil.tz import gettz
>>> tzinfos = {"BRST": -7200, "CST": gettz("America/Chicago")}
>>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos)
datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -7200))
>>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos)
datetime.datetime(2012, 1, 19, 17, 21,
tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago'))
This parameter is ignored if ``ignoretz`` is set.
:param dayfirst:
Whether to interpret the first value in an ambiguous 3-integer date
(e.g. 01/05/09) as the day (``True``) or month (``False``). If
``yearfirst`` is set to ``True``, this distinguishes between YDM and
YMD. If set to ``None``, this value is retrieved from the current
:class:`parserinfo` object (which itself defaults to ``False``).
:param yearfirst:
Whether to interpret the first value in an ambiguous 3-integer date
(e.g. 01/05/09) as the year. If ``True``, the first number is taken to
be the year, otherwise the last number is taken to be the year. If
this is set to ``None``, the value is retrieved from the current
:class:`parserinfo` object (which itself defaults to ``False``).
:param fuzzy:
Whether to allow fuzzy parsing, allowing for string like "Today is
January 1, 2047 at 8:21:00AM".
:param fuzzy_with_tokens:
If ``True``, ``fuzzy`` is automatically set to True, and the parser
will return a tuple where the first element is the parsed
:class:`datetime.datetime` datetimestamp and the second element is
a tuple containing the portions of the string which were ignored:
.. doctest::
>>> from dateutil.parser import parse
>>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True)
(datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at '))
:return:
Returns a :class:`datetime.datetime` object or, if the
``fuzzy_with_tokens`` option is ``True``, returns a tuple, the
first element being a :class:`datetime.datetime` object, the second
a tuple containing the fuzzy tokens.
:raises ParserError:
Raised for invalid or unknown string formats, if the provided
:class:`tzinfo` is not in a valid format, or if an invalid date would
be created.
:raises OverflowError:
Raised if the parsed date exceeds the largest valid C integer on
your system.
DATA
__all__ = ['parse', 'parser', 'parserinfo', 'isoparse', 'isoparser', '...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\parser\__init__.py
python-dateutil.relativedelta
Python Library Documentation: module dateutil.relativedelta in dateutil
NAME
dateutil.relativedelta - # -*- coding: utf-8 -*-
CLASSES
builtins.object
relativedelta
class relativedelta(builtins.object)
| relativedelta(dt1=None, dt2=None, years=0, months=0, days=0, leapdays=0, weeks=0, hours=0, minutes=0, seconds=0, microseconds=0, year=None, month=None, day=None, weekday=None, yearday=None, nlyearday=None, hour=None, minute=None, second=None, microsecond=None)
|
| The relativedelta type is designed to be applied to an existing datetime and
| can replace specific components of that datetime, or represents an interval
| of time.
|
| It is based on the specification of the excellent work done by M.-A. Lemburg
| in his
| `mx.DateTime <https://www.egenix.com/products/python/mxBase/mxDateTime/>`_ extension.
| However, notice that this type does *NOT* implement the same algorithm as
| his work. Do *NOT* expect it to behave like mx.DateTime's counterpart.
|
| There are two different ways to build a relativedelta instance. The
| first one is passing it two date/datetime classes::
|
| relativedelta(datetime1, datetime2)
|
| The second one is passing it any number of the following keyword arguments::
|
| relativedelta(arg1=x,arg2=y,arg3=z...)
|
| year, month, day, hour, minute, second, microsecond:
| Absolute information (argument is singular); adding or subtracting a
| relativedelta with absolute information does not perform an arithmetic
| operation, but rather REPLACES the corresponding value in the
| original datetime with the value(s) in relativedelta.
|
| years, months, weeks, days, hours, minutes, seconds, microseconds:
| Relative information, may be negative (argument is plural); adding
| or subtracting a relativedelta with relative information performs
| the corresponding arithmetic operation on the original datetime value
| with the information in the relativedelta.
|
| weekday:
| One of the weekday instances (MO, TU, etc) available in the
| relativedelta module. These instances may receive a parameter N,
| specifying the Nth weekday, which could be positive or negative
| (like MO(+1) or MO(-2)). Not specifying it is the same as specifying
| +1. You can also use an integer, where 0=MO. This argument is always
| relative e.g. if the calculated date is already Monday, using MO(1)
| or MO(-1) won't change the day. To effectively make it absolute, use
| it in combination with the day argument (e.g. day=1, MO(1) for first
| Monday of the month).
|
| leapdays:
| Will add given days to the date found, if year is a leap
| year, and the date found is post 28 of february.
|
| yearday, nlyearday:
| Set the yearday or the non-leap year day (jump leap days).
| These are converted to day/month/leapdays information.
|
| There are relative and absolute forms of the keyword
| arguments. The plural is relative, and the singular is
| absolute. For each argument in the order below, the absolute form
| is applied first (by setting each attribute to that value) and
| then the relative form (by adding the value to the attribute).
|
| The order of attributes considered when this relativedelta is
| added to a datetime is:
|
| 1. Year
| 2. Month
| 3. Day
| 4. Hours
| 5. Minutes
| 6. Seconds
| 7. Microseconds
|
| Finally, weekday is applied, using the rule described above.
|
| For example
|
| >>> from datetime import datetime
| >>> from dateutil.relativedelta import relativedelta, MO
| >>> dt = datetime(2018, 4, 9, 13, 37, 0)
| >>> delta = relativedelta(hours=25, day=1, weekday=MO(1))
| >>> dt + delta
| datetime.datetime(2018, 4, 2, 14, 37)
|
| First, the day is set to 1 (the first of the month), then 25 hours
| are added, to get to the 2nd day and 14th hour, finally the
| weekday is applied, but since the 2nd is already a Monday there is
| no effect.
|
| Methods defined here:
|
| __abs__(self)
|
| __add__(self, other)
|
| __bool__(self)
|
| __div__(self, other)
|
| __eq__(self, other)
| Return self==value.
|
| __hash__(self)
| Return hash(self).
|
| __init__(self, dt1=None, dt2=None, years=0, months=0, days=0, leapdays=0, weeks=0, hours=0, minutes=0, seconds=0, microseconds=0, year=None, month=None, day=None, weekday=None, yearday=None, nlyearday=None, hour=None, minute=None, second=None, microsecond=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __mul__(self, other)
|
| __ne__(self, other)
| Return self!=value.
|
| __neg__(self)
|
| __nonzero__ = __bool__(self)
|
| __radd__(self, other)
|
| __repr__(self)
| Return repr(self).
|
| __rmul__ = __mul__(self, other)
|
| __rsub__(self, other)
|
| __sub__(self, other)
|
| __truediv__ = __div__(self, other)
|
| normalized(self)
| Return a version of this object represented entirely using integer
| values for the relative attributes.
|
| >>> relativedelta(days=1.5, hours=2).normalized()
| relativedelta(days=+1, hours=+14)
|
| :return:
| Returns a :class:`dateutil.relativedelta.relativedelta` object.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| weeks
DATA
FR = FR
MO = MO
SA = SA
SU = SU
TH = TH
TU = TU
WE = WE
__all__ = ['relativedelta', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\relativedelta.py
python-dateutil.rrule
Python Library Documentation: module dateutil.rrule in dateutil
NAME
dateutil.rrule
DESCRIPTION
The rrule module offers a small, complete, and very fast, implementation of
the recurrence rules documented in the
`iCalendar RFC <https://tools.ietf.org/html/rfc5545>`_,
including support for caching of results.
CLASSES
rrulebase(builtins.object)
rrule
rruleset
class rrule(rrulebase)
| rrule(freq, dtstart=None, interval=1, wkst=None, count=None, until=None, bysetpos=None, bymonth=None, bymonthday=None, byyearday=None, byeaster=None, byweekno=None, byweekday=None, byhour=None, byminute=None, bysecond=None, cache=False)
|
| That's the base of the rrule operation. It accepts all the keywords
| defined in the RFC as its constructor parameters (except byday,
| which was renamed to byweekday) and more. The constructor prototype is::
|
| rrule(freq)
|
| Where freq must be one of YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
| or SECONDLY.
|
| .. note::
| Per RFC section 3.3.10, recurrence instances falling on invalid dates
| and times are ignored rather than coerced:
|
| Recurrence rules may generate recurrence instances with an invalid
| date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM
| on a day where the local time is moved forward by an hour at 1:00
| AM). Such recurrence instances MUST be ignored and MUST NOT be
| counted as part of the recurrence set.
|
| This can lead to possibly surprising behavior when, for example, the
| start date occurs at the end of the month:
|
| >>> from dateutil.rrule import rrule, MONTHLY
| >>> from datetime import datetime
| >>> start_date = datetime(2014, 12, 31)
| >>> list(rrule(freq=MONTHLY, count=4, dtstart=start_date))
| ... # doctest: +NORMALIZE_WHITESPACE
| [datetime.datetime(2014, 12, 31, 0, 0),
| datetime.datetime(2015, 1, 31, 0, 0),
| datetime.datetime(2015, 3, 31, 0, 0),
| datetime.datetime(2015, 5, 31, 0, 0)]
|
| Additionally, it supports the following keyword arguments:
|
| :param dtstart:
| The recurrence start. Besides being the base for the recurrence,
| missing parameters in the final recurrence instances will also be
| extracted from this date. If not given, datetime.now() will be used
| instead.
| :param interval:
| The interval between each freq iteration. For example, when using
| YEARLY, an interval of 2 means once every two years, but with HOURLY,
| it means once every two hours. The default interval is 1.
| :param wkst:
| The week start day. Must be one of the MO, TU, WE constants, or an
| integer, specifying the first day of the week. This will affect
| recurrences based on weekly periods. The default week start is got
| from calendar.firstweekday(), and may be modified by
| calendar.setfirstweekday().
| :param count:
| If given, this determines how many occurrences will be generated.
|
| .. note::
| As of version 2.5.0, the use of the keyword ``until`` in conjunction
| with ``count`` is deprecated, to make sure ``dateutil`` is fully
| compliant with `RFC-5545 Sec. 3.3.10 <https://tools.ietf.org/
| html/rfc5545#section-3.3.10>`_. Therefore, ``until`` and ``count``
| **must not** occur in the same call to ``rrule``.
| :param until:
| If given, this must be a datetime instance specifying the upper-bound
| limit of the recurrence. The last recurrence in the rule is the greatest
| datetime that is less than or equal to the value specified in the
| ``until`` parameter.
|
| .. note::
| As of version 2.5.0, the use of the keyword ``until`` in conjunction
| with ``count`` is deprecated, to make sure ``dateutil`` is fully
| compliant with `RFC-5545 Sec. 3.3.10 <https://tools.ietf.org/
| html/rfc5545#section-3.3.10>`_. Therefore, ``until`` and ``count``
| **must not** occur in the same call to ``rrule``.
| :param bysetpos:
| If given, it must be either an integer, or a sequence of integers,
| positive or negative. Each given integer will specify an occurrence
| number, corresponding to the nth occurrence of the rule inside the
| frequency period. For example, a bysetpos of -1 if combined with a
| MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will
| result in the last work day of every month.
| :param bymonth:
| If given, it must be either an integer, or a sequence of integers,
| meaning the months to apply the recurrence to.
| :param bymonthday:
| If given, it must be either an integer, or a sequence of integers,
| meaning the month days to apply the recurrence to.
| :param byyearday:
| If given, it must be either an integer, or a sequence of integers,
| meaning the year days to apply the recurrence to.
| :param byeaster:
| If given, it must be either an integer, or a sequence of integers,
| positive or negative. Each integer will define an offset from the
| Easter Sunday. Passing the offset 0 to byeaster will yield the Easter
| Sunday itself. This is an extension to the RFC specification.
| :param byweekno:
| If given, it must be either an integer, or a sequence of integers,
| meaning the week numbers to apply the recurrence to. Week numbers
| have the meaning described in ISO8601, that is, the first week of
| the year is that containing at least four days of the new year.
| :param byweekday:
| If given, it must be either an integer (0 == MO), a sequence of
| integers, one of the weekday constants (MO, TU, etc), or a sequence
| of these constants. When given, these variables will define the
| weekdays where the recurrence will be applied. It's also possible to
| use an argument n for the weekday instances, which will mean the nth
| occurrence of this weekday in the period. For example, with MONTHLY,
| or with YEARLY and BYMONTH, using FR(+1) in byweekday will specify the
| first friday of the month where the recurrence happens. Notice that in
| the RFC documentation, this is specified as BYDAY, but was renamed to
| avoid the ambiguity of that keyword.
| :param byhour:
| If given, it must be either an integer, or a sequence of integers,
| meaning the hours to apply the recurrence to.
| :param byminute:
| If given, it must be either an integer, or a sequence of integers,
| meaning the minutes to apply the recurrence to.
| :param bysecond:
| If given, it must be either an integer, or a sequence of integers,
| meaning the seconds to apply the recurrence to.
| :param cache:
| If given, it must be a boolean value specifying to enable or disable
| caching of results. If you will use the same rrule instance multiple
| times, enabling caching will improve the performance considerably.
|
| Method resolution order:
| rrule
| rrulebase
| builtins.object
|
| Methods defined here:
|
| __init__(self, freq, dtstart=None, interval=1, wkst=None, count=None, until=None, bysetpos=None, bymonth=None, bymonthday=None, byyearday=None, byeaster=None, byweekno=None, byweekday=None, byhour=None, byminute=None, bysecond=None, cache=False)
| Initialize self. See help(type(self)) for accurate signature.
|
| __str__(self)
| Output a string that would generate this RRULE if passed to rrulestr.
| This is mostly compatible with RFC5545, except for the
| dateutil-specific extension BYEASTER.
|
| replace(self, **kwargs)
| Return new rrule with same attributes except for those attributes given new
| values by whichever keyword arguments are specified.
|
| ----------------------------------------------------------------------
| Methods inherited from rrulebase:
|
| __contains__(self, item)
|
| __getitem__(self, item)
|
| __iter__(self)
|
| after(self, dt, inc=False)
| Returns the first recurrence after the given datetime instance. The
| inc keyword defines what happens if dt is an occurrence. With
| inc=True, if dt itself is an occurrence, it will be returned.
|
| before(self, dt, inc=False)
| Returns the last recurrence before the given datetime instance. The
| inc keyword defines what happens if dt is an occurrence. With
| inc=True, if dt itself is an occurrence, it will be returned.
|
| between(self, after, before, inc=False, count=1)
| Returns all the occurrences of the rrule between after and before.
| The inc keyword defines what happens if after and/or before are
| themselves occurrences. With inc=True, they will be included in the
| list, if they are found in the recurrence set.
|
| count(self)
| Returns the number of recurrences in this set. It will have go
| through the whole recurrence, if this hasn't been done before.
|
| xafter(self, dt, count=None, inc=False)
| Generator which yields up to `count` recurrences after the given
| datetime instance, equivalent to `after`.
|
| :param dt:
| The datetime at which to start generating recurrences.
|
| :param count:
| The maximum number of recurrences to generate. If `None` (default),
| dates are generated until the recurrence rule is exhausted.
|
| :param inc:
| If `dt` is an instance of the rule and `inc` is `True`, it is
| included in the output.
|
| :yields: Yields a sequence of `datetime` objects.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from rrulebase:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class rruleset(rrulebase)
| rruleset(cache=False)
|
| The rruleset type allows more complex recurrence setups, mixing
| multiple rules, dates, exclusion rules, and exclusion dates. The type
| constructor takes the following keyword arguments:
|
| :param cache: If True, caching of results will be enabled, improving
| performance of multiple queries considerably.
|
| Method resolution order:
| rruleset
| rrulebase
| builtins.object
|
| Methods defined here:
|
| __init__(self, cache=False)
| Initialize self. See help(type(self)) for accurate signature.
|
| exdate(self, exdate)
| Include the given datetime instance in the recurrence set
| exclusion list. Dates included that way will not be generated,
| even if some inclusive rrule or rdate matches them.
|
| exrule(self, exrule)
| Include the given rrule instance in the recurrence set exclusion
| list. Dates which are part of the given recurrence rules will not
| be generated, even if some inclusive rrule or rdate matches them.
|
| rdate(self, rdate)
| Include the given :py:class:`datetime` instance in the recurrence
| set generation.
|
| rrule(self, rrule)
| Include the given :py:class:`rrule` instance in the recurrence set
| generation.
|
| ----------------------------------------------------------------------
| Methods inherited from rrulebase:
|
| __contains__(self, item)
|
| __getitem__(self, item)
|
| __iter__(self)
|
| after(self, dt, inc=False)
| Returns the first recurrence after the given datetime instance. The
| inc keyword defines what happens if dt is an occurrence. With
| inc=True, if dt itself is an occurrence, it will be returned.
|
| before(self, dt, inc=False)
| Returns the last recurrence before the given datetime instance. The
| inc keyword defines what happens if dt is an occurrence. With
| inc=True, if dt itself is an occurrence, it will be returned.
|
| between(self, after, before, inc=False, count=1)
| Returns all the occurrences of the rrule between after and before.
| The inc keyword defines what happens if after and/or before are
| themselves occurrences. With inc=True, they will be included in the
| list, if they are found in the recurrence set.
|
| count(self)
| Returns the number of recurrences in this set. It will have go
| through the whole recurrence, if this hasn't been done before.
|
| xafter(self, dt, count=None, inc=False)
| Generator which yields up to `count` recurrences after the given
| datetime instance, equivalent to `after`.
|
| :param dt:
| The datetime at which to start generating recurrences.
|
| :param count:
| The maximum number of recurrences to generate. If `None` (default),
| dates are generated until the recurrence rule is exhausted.
|
| :param inc:
| If `dt` is an instance of the rule and `inc` is `True`, it is
| included in the output.
|
| :yields: Yields a sequence of `datetime` objects.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from rrulebase:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
DAILY = 3
FR = FR
HOURLY = 4
MINUTELY = 5
MO = MO
MONTHLY = 1
SA = SA
SECONDLY = 6
SU = SU
TH = TH
TU = TU
WE = WE
WEEKLY = 2
YEARLY = 0
__all__ = ['rrule', 'rruleset', 'rrulestr', 'YEARLY', 'MONTHLY', 'WEEK...
rrulestr = <dateutil.rrule._rrulestr object>
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\rrule.py
python-dateutil.tz
Python Library Documentation: package dateutil.tz in dateutil
NAME
dateutil.tz
DESCRIPTION
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.
PACKAGE CONTENTS
_common
_factories
tz
win
CLASSES
builtins.Warning(builtins.Exception)
DeprecatedTzFormatWarning
builtins.object
dateutil.tz.tz.tzical
datetime.tzinfo(builtins.object)
dateutil.tz.tz.tzoffset
dateutil.tz.tz.tzutc
dateutil.tz._common._tzinfo(datetime.tzinfo)
dateutil.tz.tz.tzfile
dateutil.tz.tz.tzlocal
dateutil.tz._common.tzrangebase(dateutil.tz._common._tzinfo)
dateutil.tz.tz.tzrange
dateutil.tz.tz.tzstr
dateutil.tz.win.tzwinbase(dateutil.tz._common.tzrangebase)
dateutil.tz.win.tzwin
dateutil.tz.win.tzwinlocal
class DeprecatedTzFormatWarning(builtins.Warning)
| Warning raised when time zones are parsed from deprecated formats.
|
| Method resolution order:
| DeprecatedTzFormatWarning
| builtins.Warning
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Warning:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Warning:
|
| __new__(*args, **kwargs) class method of builtins.Warning
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| 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 tzfile(dateutil.tz._common._tzinfo)
| tzfile(fileobj, filename=None)
|
| This is a ``tzinfo`` subclass that allows one to use the ``tzfile(5)``
| format timezone files to extract current and historical zone information.
|
| :param fileobj:
| This can be an opened file stream or a file name that the time zone
| information can be read from.
|
| :param filename:
| This is an optional parameter specifying the source of the time zone
| information in the event that ``fileobj`` is a file object. If omitted
| and ``fileobj`` is a file stream, this parameter will be set either to
| ``fileobj``'s ``name`` attribute or to ``repr(fileobj)``.
|
| See `Sources for Time Zone and Daylight Saving Time Data
| <https://data.iana.org/time-zones/tz-link.html>`_ for more information.
| Time zone files can be compiled from the `IANA Time Zone database files
| <https://www.iana.org/time-zones>`_ with the `zic time zone compiler
| <https://www.freebsd.org/cgi/man.cgi?query=zic&sektion=8>`_
|
| .. note::
|
| Only construct a ``tzfile`` directly if you have a specific timezone
| file on disk that you want to read into a Python ``tzinfo`` object.
| If you want to get a ``tzfile`` representing a specific IANA zone,
| (e.g. ``'America/New_York'``), you should call
| :func:`dateutil.tz.gettz` with the zone identifier.
|
|
| **Examples:**
|
| Using the US Eastern time zone as an example, we can see that a ``tzfile``
| provides time zone information for the standard Daylight Saving offsets:
|
| .. testsetup:: tzfile
|
| from dateutil.tz import gettz
| from datetime import datetime
|
| .. doctest:: tzfile
|
| >>> NYC = gettz('America/New_York')
| >>> NYC
| tzfile('/usr/share/zoneinfo/America/New_York')
|
| >>> print(datetime(2016, 1, 3, tzinfo=NYC)) # EST
| 2016-01-03 00:00:00-05:00
|
| >>> print(datetime(2016, 7, 7, tzinfo=NYC)) # EDT
| 2016-07-07 00:00:00-04:00
|
|
| The ``tzfile`` structure contains a fully history of the time zone,
| so historical dates will also have the right offsets. For example, before
| the adoption of the UTC standards, New York used local solar mean time:
|
| .. doctest:: tzfile
|
| >>> print(datetime(1901, 4, 12, tzinfo=NYC)) # LMT
| 1901-04-12 00:00:00-04:56
|
| And during World War II, New York was on "Eastern War Time", which was a
| state of permanent daylight saving time:
|
| .. doctest:: tzfile
|
| >>> print(datetime(1944, 2, 7, tzinfo=NYC)) # EWT
| 1944-02-07 00:00:00-04:00
|
| Method resolution order:
| tzfile
| dateutil.tz._common._tzinfo
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __eq__(self, other)
| Return self==value.
|
| __init__(self, fileobj, filename=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ne__(self, other)
| Return self!=value.
|
| __reduce__(self)
| -> (cls, state)
|
| __reduce_ex__(self, protocol)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`.
|
| :param dt:
| A :py:class:`datetime.datetime` object.
|
| :raises TypeError:
| Raised if ``dt`` is not a :py:class:`datetime.datetime` object.
|
| :raises ValueError:
| Raised if this is called with a ``dt`` which does not have this
| ``tzinfo`` attached.
|
| :return:
| Returns a :py:class:`datetime.datetime` object representing the
| wall time in ``self``'s time zone.
|
| is_ambiguous(self, dt, idx=None)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from dateutil.tz._common._tzinfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzical(builtins.object)
| tzical(fileobj)
|
| 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.
|
| :param `fileobj`:
| A file or stream in iCalendar format, which should be UTF-8 encoded
| with CRLF endings.
|
| .. _`RFC 5545`: https://tools.ietf.org/html/rfc5545
|
| Methods defined here:
|
| __init__(self, fileobj)
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self)
| Return repr(self).
|
| get(self, tzid=None)
| Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``.
|
| :param tzid:
| If there is exactly one time zone available, omitting ``tzid``
| or passing :py:const:`None` value returns it. Otherwise a valid
| key (which can be retrieved from :func:`keys`) is required.
|
| :raises ValueError:
| Raised if ``tzid`` is not specified but there are either more
| or fewer than 1 zone defined.
|
| :returns:
| Returns either a :py:class:`datetime.tzinfo` object representing
| the relevant time zone or :py:const:`None` if the ``tzid`` was
| not found.
|
| keys(self)
| Retrieves the available time zones as a list.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class tzlocal(dateutil.tz._common._tzinfo)
| A :class:`tzinfo` subclass built around the ``time`` timezone functions.
|
| Method resolution order:
| tzlocal
| dateutil.tz._common._tzinfo
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __eq__(self, other)
| Return self==value.
|
| __init__(self)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ne__(self, other)
| Return self!=value.
|
| __reduce__(self, /) from builtins.object
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from dateutil.tz._common._tzinfo:
|
| fromutc(self, dt)
| Given a timezone-aware datetime in a given timezone, calculates a
| timezone-aware datetime in a new timezone.
|
| Since this is the one time that we *know* we have an unambiguous
| datetime object, we take this opportunity to determine whether the
| datetime is ambiguous and in a "fold" state (e.g. if it's the first
| occurrence, chronologically, of the ambiguous datetime).
|
| :param dt:
| A timezone-aware :class:`datetime.datetime` object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from dateutil.tz._common._tzinfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzoffset(datetime.tzinfo)
| tzoffset(name, offset)
|
| A simple class for representing a fixed offset from UTC.
|
| :param name:
| The timezone name, to be returned when ``tzname()`` is called.
| :param offset:
| The time zone offset in seconds, or (since version 2.6.0, represented
| as a :py:class:`datetime.timedelta` object).
|
| Method resolution order:
| tzoffset
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __eq__(self, other)
| Return self==value.
|
| __init__(self, name, offset)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ne__(self, other)
| Return self!=value.
|
| __reduce__(self, /) from builtins.object
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| datetime in UTC -> datetime in local time.
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzrange(dateutil.tz._common.tzrangebase)
| tzrange(stdabbr, stdoffset=None, dstabbr=None, dstoffset=None, start=None, end=None)
|
| 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.
|
| :param stdabbr:
| The abbreviation for standard time (e.g. ``'EST'``).
|
| :param stdoffset:
| An integer or :class:`datetime.timedelta` object or equivalent
| specifying the base offset from UTC.
|
| If unspecified, +00:00 is used.
|
| :param dstabbr:
| The abbreviation for DST / "Summer" time (e.g. ``'EDT'``).
|
| If specified, with no other DST information, DST is assumed to occur
| and the default behavior or ``dstoffset``, ``start`` and ``end`` is
| used. If unspecified and no other DST information is specified, it
| is assumed that this zone has no DST.
|
| If this is unspecified and other DST information is *is* specified,
| DST occurs in the zone but the time zone abbreviation is left
| unchanged.
|
| :param dstoffset:
| A an integer or :class:`datetime.timedelta` object or equivalent
| specifying the UTC offset during DST. If unspecified and any other DST
| information is specified, it is assumed to be the STD offset +1 hour.
|
| :param start:
| A :class:`relativedelta.relativedelta` object or equivalent specifying
| the time and time of year that daylight savings time starts. To
| specify, for example, that DST starts at 2AM on the 2nd Sunday in
| March, pass:
|
| ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))``
|
| If unspecified and any other DST information is specified, the default
| value is 2 AM on the first Sunday in April.
|
| :param end:
| A :class:`relativedelta.relativedelta` object or equivalent
| representing the time and time of year that daylight savings time
| ends, with the same specification method as in ``start``. One note is
| that this should point to the first time in the *standard* zone, so if
| a transition occurs at 2AM in the DST zone and the clocks are set back
| 1 hour to 1AM, set the ``hours`` parameter to +1.
|
|
| **Examples:**
|
| .. testsetup:: tzrange
|
| from dateutil.tz import tzrange, tzstr
|
| .. doctest:: tzrange
|
| >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT")
| True
|
| >>> from dateutil.relativedelta import *
| >>> range1 = tzrange("EST", -18000, "EDT")
| >>> range2 = tzrange("EST", -18000, "EDT", -14400,
| ... relativedelta(hours=+2, month=4, day=1,
| ... weekday=SU(+1)),
| ... relativedelta(hours=+1, month=10, day=31,
| ... weekday=SU(-1)))
| >>> tzstr('EST5EDT') == range1 == range2
| True
|
| Method resolution order:
| tzrange
| dateutil.tz._common.tzrangebase
| dateutil.tz._common._tzinfo
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __eq__(self, other)
| Return self==value.
|
| __init__(self, stdabbr, stdoffset=None, dstabbr=None, dstoffset=None, start=None, end=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| transitions(self, year)
| For a given year, get the DST on and off transition times, expressed
| always on the standard time side. For zones with no transitions, this
| function returns ``None``.
|
| :param year:
| The year whose transitions you would like to query.
|
| :return:
| Returns a :class:`tuple` of :class:`datetime.datetime` objects,
| ``(dston, dstoff)`` for zones with an annual DST transition, or
| ``None`` for fixed offset zones.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from dateutil.tz._common.tzrangebase:
|
| __ne__(self, other)
| Return self!=value.
|
| __reduce__(self, /) from builtins.object
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| Given a datetime in UTC, return local time
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data descriptors inherited from dateutil.tz._common._tzinfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzstr(tzrange)
| tzstr(s, posix_offset=False)
|
| ``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).
|
| There is one notable exception, which is that POSIX-style time zones use an
| inverted offset format, so normally ``GMT+3`` would be parsed as an offset
| 3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an
| offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX
| behavior, pass a ``True`` value to ``posix_offset``.
|
| The :class:`tzrange` object provides the same functionality, but is
| specified using :class:`relativedelta.relativedelta` objects. rather than
| strings.
|
| :param s:
| A time zone string in ``TZ`` variable format. This can be a
| :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x:
| :class:`unicode`) or a stream emitting unicode characters
| (e.g. :class:`StringIO`).
|
| :param posix_offset:
| Optional. If set to ``True``, interpret strings such as ``GMT+3`` or
| ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the
| POSIX standard.
|
| .. caution::
|
| Prior to version 2.7.0, this function also supported time zones
| in the format:
|
| * ``EST5EDT,4,0,6,7200,10,0,26,7200,3600``
| * ``EST5EDT,4,1,0,7200,10,-1,0,7200,3600``
|
| This format is non-standard and has been deprecated; this function
| will raise a :class:`DeprecatedTZFormatWarning` until
| support is removed in a future version.
|
| .. _`GNU C Library: TZ Variable`:
| https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
|
| Method resolution order:
| tzstr
| tzrange
| dateutil.tz._common.tzrangebase
| dateutil.tz._common._tzinfo
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __init__(self, s, posix_offset=False)
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Methods inherited from tzrange:
|
| __eq__(self, other)
| Return self==value.
|
| transitions(self, year)
| For a given year, get the DST on and off transition times, expressed
| always on the standard time side. For zones with no transitions, this
| function returns ``None``.
|
| :param year:
| The year whose transitions you would like to query.
|
| :return:
| Returns a :class:`tuple` of :class:`datetime.datetime` objects,
| ``(dston, dstoff)`` for zones with an annual DST transition, or
| ``None`` for fixed offset zones.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from tzrange:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from dateutil.tz._common.tzrangebase:
|
| __ne__(self, other)
| Return self!=value.
|
| __reduce__(self, /) from builtins.object
| Helper for pickle.
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| Given a datetime in UTC, return local time
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data descriptors inherited from dateutil.tz._common._tzinfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzutc(datetime.tzinfo)
| This is a tzinfo object that represents the UTC time zone.
|
| **Examples:**
|
| .. doctest::
|
| >>> from datetime import *
| >>> from dateutil.tz import *
|
| >>> datetime.now()
| datetime.datetime(2003, 9, 27, 9, 40, 1, 521290)
|
| >>> datetime.now(tzutc())
| datetime.datetime(2003, 9, 27, 12, 40, 12, 156379, tzinfo=tzutc())
|
| >>> datetime.now(tzutc()).tzname()
| 'UTC'
|
| .. versionchanged:: 2.7.0
| ``tzutc()`` is now a singleton, so the result of ``tzutc()`` will
| always return the same object.
|
| .. doctest::
|
| >>> from dateutil.tz import tzutc, UTC
| >>> tzutc() is tzutc()
| True
| >>> tzutc() is UTC
| True
|
| Method resolution order:
| tzutc
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __eq__(self, other)
| Return self==value.
|
| __ne__(self, other)
| Return self!=value.
|
| __reduce__(self, /) from builtins.object
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| Fast track version of fromutc() returns the original ``dt`` object for
| any valid :py:class:`datetime.datetime` object.
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzwin(tzwinbase)
| tzwin(name)
|
| Time zone object created from the zone info in the Windows registry
|
| These are similar to :py:class:`dateutil.tz.tzrange` objects in that
| the time zone data is provided in the format of a single offset rule
| for either 0 or 2 time zone transitions per year.
|
| :param: name
| The name of a Windows time zone key, e.g. "Eastern Standard Time".
| The full list of keys can be retrieved with :func:`tzwin.list`.
|
| Method resolution order:
| tzwin
| tzwinbase
| dateutil.tz._common.tzrangebase
| dateutil.tz._common._tzinfo
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __init__(self, name)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Methods inherited from tzwinbase:
|
| __eq__(self, other)
| Return self==value.
|
| display(self)
| Return the display name of the time zone.
|
| transitions(self, year)
| For a given year, get the DST on and off transition times, expressed
| always on the standard time side. For zones with no transitions, this
| function returns ``None``.
|
| :param year:
| The year whose transitions you would like to query.
|
| :return:
| Returns a :class:`tuple` of :class:`datetime.datetime` objects,
| ``(dston, dstoff)`` for zones with an annual DST transition, or
| ``None`` for fixed offset zones.
|
| ----------------------------------------------------------------------
| Static methods inherited from tzwinbase:
|
| list()
| Return a list of all time zones known to the system.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from tzwinbase:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from dateutil.tz._common.tzrangebase:
|
| __ne__(self, other)
| Return self!=value.
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| Given a datetime in UTC, return local time
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data descriptors inherited from dateutil.tz._common._tzinfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
class tzwinlocal(tzwinbase)
| Class representing the local time zone information in the Windows registry
|
| While :class:`dateutil.tz.tzlocal` makes system calls (via the :mod:`time`
| module) to retrieve time zone information, ``tzwinlocal`` retrieves the
| rules directly from the Windows registry and creates an object like
| :class:`dateutil.tz.tzwin`.
|
| Because Windows does not have an equivalent of :func:`time.tzset`, on
| Windows, :class:`dateutil.tz.tzlocal` instances will always reflect the
| time zone settings *at the time that the process was started*, meaning
| changes to the machine's time zone settings during the run of a program
| on Windows will **not** be reflected by :class:`dateutil.tz.tzlocal`.
| Because ``tzwinlocal`` reads the registry directly, it is unaffected by
| this issue.
|
| Method resolution order:
| tzwinlocal
| tzwinbase
| dateutil.tz._common.tzrangebase
| dateutil.tz._common._tzinfo
| datetime.tzinfo
| builtins.object
|
| Methods defined here:
|
| __init__(self)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| __str__(self)
| Return str(self).
|
| ----------------------------------------------------------------------
| Methods inherited from tzwinbase:
|
| __eq__(self, other)
| Return self==value.
|
| display(self)
| Return the display name of the time zone.
|
| transitions(self, year)
| For a given year, get the DST on and off transition times, expressed
| always on the standard time side. For zones with no transitions, this
| function returns ``None``.
|
| :param year:
| The year whose transitions you would like to query.
|
| :return:
| Returns a :class:`tuple` of :class:`datetime.datetime` objects,
| ``(dston, dstoff)`` for zones with an annual DST transition, or
| ``None`` for fixed offset zones.
|
| ----------------------------------------------------------------------
| Static methods inherited from tzwinbase:
|
| list()
| Return a list of all time zones known to the system.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from tzwinbase:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from dateutil.tz._common.tzrangebase:
|
| __ne__(self, other)
| Return self!=value.
|
| dst(self, dt)
| datetime -> DST offset as timedelta positive east of UTC.
|
| fromutc(self, dt)
| Given a datetime in UTC, return local time
|
| is_ambiguous(self, dt)
| Whether or not the "wall time" of a given datetime is ambiguous in this
| zone.
|
| :param dt:
| A :py:class:`datetime.datetime`, naive or time zone aware.
|
|
| :return:
| Returns ``True`` if ambiguous, ``False`` otherwise.
|
| .. versionadded:: 2.6.0
|
| tzname(self, dt)
| datetime -> string name of time zone.
|
| utcoffset(self, dt)
| datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
|
| ----------------------------------------------------------------------
| Data descriptors inherited from dateutil.tz._common._tzinfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from datetime.tzinfo:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| ----------------------------------------------------------------------
| Static methods inherited from datetime.tzinfo:
|
| __new__(*args, **kwargs) class method of datetime.tzinfo
| Create and return a new object. See help(type) for accurate signature.
FUNCTIONS
datetime_ambiguous(dt, tz=None)
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
datetime_exists(dt, tz=None)
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
enfold(dt, fold=1)
Provides a unified interface for assigning the ``fold`` attribute to
datetimes both before and after the implementation of PEP-495.
:param fold:
The value for the ``fold`` attribute in the returned datetime. This
should be either 0 or 1.
:return:
Returns an object for which ``getattr(dt, 'fold', 0)`` returns
``fold`` for all versions of Python. In versions prior to
Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
subclass of :py:class:`datetime.datetime` with the ``fold``
attribute added, if ``fold`` is 1.
.. versionadded:: 2.6.0
resolve_imaginary(dt)
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
DATA
UTC = tzutc()
__all__ = ['tzutc', 'tzoffset', 'tzlocal', 'tzfile', 'tzrange', 'tzstr...
gettz = <dateutil.tz.tz.__get_gettz.<locals>.GettzFunc object>
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\tz\__init__.py
python-dateutil.utils
Python Library Documentation: module dateutil.utils in dateutil
NAME
dateutil.utils
DESCRIPTION
This module offers general convenience and utility functions for dealing with
datetimes.
.. versionadded:: 2.7.0
FUNCTIONS
default_tzinfo(dt, tzinfo)
Sets the ``tzinfo`` parameter on naive datetimes only
This is useful for example when you are provided a datetime that may have
either an implicit or explicit time zone, such as when parsing a time zone
string.
.. doctest::
>>> from dateutil.tz import tzoffset
>>> from dateutil.parser import parse
>>> from dateutil.utils import default_tzinfo
>>> dflt_tz = tzoffset("EST", -18000)
>>> print(default_tzinfo(parse('2014-01-01 12:30 UTC'), dflt_tz))
2014-01-01 12:30:00+00:00
>>> print(default_tzinfo(parse('2014-01-01 12:30'), dflt_tz))
2014-01-01 12:30:00-05:00
:param dt:
The datetime on which to replace the time zone
:param tzinfo:
The :py:class:`datetime.tzinfo` subclass instance to assign to
``dt`` if (and only if) it is naive.
:return:
Returns an aware :py:class:`datetime.datetime`.
today(tzinfo=None)
Returns a :py:class:`datetime` representing the current day at midnight
:param tzinfo:
The time zone to attach (also used to determine the current day).
:return:
A :py:class:`datetime.datetime` object representing the current day
at midnight.
within_delta(dt1, dt2, delta)
Useful for comparing two datetimes that may have a negligible difference
to be considered equal.
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\utils.py
python-dateutil.zoneinfo
Python Library Documentation: package dateutil.zoneinfo in dateutil
NAME
dateutil.zoneinfo - # -*- coding: utf-8 -*-
PACKAGE CONTENTS
rebuild
FUNCTIONS
get_zonefile_instance(new_instance=False)
This is a convenience function which provides a :class:`ZoneInfoFile`
instance using the data provided by the ``dateutil`` package. By default, it
caches a single instance of the ZoneInfoFile object and returns that.
:param new_instance:
If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and
used as the cached instance for the next call. Otherwise, new instances
are created only as necessary.
:return:
Returns a :class:`ZoneInfoFile` object.
.. versionadded:: 2.6
gettz(name)
This retrieves a time zone from the local zoneinfo tarball that is packaged
with dateutil.
:param name:
An IANA-style time zone name, as found in the zoneinfo file.
:return:
Returns a :class:`dateutil.tz.tzfile` time zone object.
.. warning::
It is generally inadvisable to use this function, and it is only
provided for API compatibility with earlier versions. This is *not*
equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
time zone based on the inputs, favoring system zoneinfo. This is ONLY
for accessing the dateutil-specific zoneinfo (which may be out of
date compared to the system zoneinfo).
.. deprecated:: 2.6
If you need to use a specific zoneinfofile over the system zoneinfo,
instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
:func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.
Use :func:`get_zonefile_instance` to retrieve an instance of the
dateutil-provided zoneinfo.
gettz_db_metadata()
Get the zonefile metadata
See `zonefile_metadata`_
:returns:
A dictionary with the database metadata
.. deprecated:: 2.6
See deprecation warning in :func:`zoneinfo.gettz`. To get metadata,
query the attribute ``zoneinfo.ZoneInfoFile.metadata``.
DATA
__all__ = ['get_zonefile_instance', 'gettz', 'gettz_db_metadata']
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\dateutil\zoneinfo\__init__.py