3
6ÈcYÖ. ã @ s´ d dl mZ d dlmZ d dlmZmZmZ ed ƒZddgZdd„ Z e
edƒrZdd d„ZnG d
d„ deƒZddd„Zd
d„ Z
G dd„ deƒZG dd„ deƒZdd„ ZeedeƒZdS )é )ÚPY3)Úwraps)ÚdatetimeÚ timedeltaÚtzinfoÚtzname_in_python2Úenfoldc s ‡ fdd„}|S )zžChange unicode output into bytestrings in Python 2
tzname() API changed in Python 3. It used to return bytes, but was changed
to unicode strings
c s$ ˆ | |Ž}|d k r t r |jƒ }|S )N)r Úencode)ÚargsÚkwargsÚname)Únamefunc© ú/usr/lib/python3.6/_common.pyÚadjust_encoding s
z*tzname_in_python2..adjust_encodingr )r
r r )r
r r
s Úfoldé c C s | j |d�S )a®
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
)r )Úreplace)Údtr r r r r ! s c @ s e Zd ZdZf Zedd„ ƒZdS )Ú_DatetimeWithFoldzö
This is a class designed to provide a PEP 495-compliant interface for
Python versions before 3.6. It is used only for dates in a fold, so
the ``fold`` attribute is fixed at ``1``.
.. versionadded:: 2.6.0
c C s dS )Nr r )Úselfr r r r @ s z_DatetimeWithFold.foldN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú __slots__Úpropertyr r r r r r 6 s r c C sL t | ddƒ|kr| S | jƒ dd… }|| j| jf7 }|r@t|Ž S t|Ž S dS )a®
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
r r Né )ÚgetattrZ timetupleZmicrosecondr r r )r r r
r r r r D s c s t ˆ ƒ‡ fdd„ƒ}|S )z�
The CPython version of ``fromutc`` checks that the input is a ``datetime``
object and that ``self`` is attached as its ``tzinfo``.
c s. t |tƒstdƒ‚|j| k r$tdƒ‚ˆ | |ƒS )Nz&fromutc() requires a datetime argumentzdt.tzinfo is not self)Ú
isinstancer Ú TypeErrorr Ú
ValueError)r r )Úfr r Úfromutcg s
z)_validate_fromutc_inputs..fromutc)r )r" r# r )r" r Ú_validate_fromutc_inputsb s r$ c @ s<