Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/dateutil/tz/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/dateutil/tz/__pycache__/_common.cpython-35.opt-1.pyc



�!X�-�@sddlmZddlmZddlmZmZmZddlZed�ZddgZ	dd�Z
eed�r�d	d
d�Zn%Gdd�de�Z
d	d
d�ZGdd�de�ZGdd�de�Zdd�Zeede�ZdS)�)�PY3)�_thread)�datetime�	timedelta�tzinfoN�tzname_in_python2�enfoldcs�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
    cs2�||�}|dk	r.tr.|j�}|S)N)r�encode)�args�kwargs�name)�namefunc��D/opt/alt/python35/lib/python3.5/site-packages/dateutil/tz/_common.py�adjust_encodingsz*tzname_in_python2.<locals>.adjust_encodingr)r
rr)r
rrs�fold�cCs|jd|�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)�dtrrrrr sc@s.eZdZdZfZedd��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
        cCsdS)Nrr)�selfrrrr?sz_DatetimeWithFold.foldN)�__name__�
__module__�__qualname__�__doc__�	__slots__�propertyrrrrrr5srcCsft|dd�|kr|S|j�dd�}||j|jf7}|rXt|�St|�SdS)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
        rrN�)�getattrZ	timetupleZmicrosecondrrr)rrr
rrrrCs
c@sReZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�_tzinfoz=
    Base class for all ``dateutil`` ``tzinfo`` objects.
    cCs}|jd|�}t|dd�}t|dd�}|j�|j�k}|jdd�|jdd�k}|o||S)a5
        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
        rrrrN)rr�	utcoffset)rrZwall_0Zwall_1Zsame_offsetZsame_dtrrr�is_ambiguousfs$z_tzinfo.is_ambiguouscCsH|j|�r>||}t||j�|j�k�}nd}|S)a�
        Determine the fold status of a "wall" datetime, given a representation
        of the same datetime as a (naive) UTC datetime. This is calculated based
        on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
        datetimes, and that this offset is the actual number of hours separating
        ``dt_utc`` and ``dt_wall``.

        :param dt_utc:
            Representation of the datetime as UTC

        :param dt_wall:
            Representation of the datetime as "wall time". This parameter must
            either have a `fold` attribute or have a fold-naive
            :class:`datetime.tzinfo` attached, otherwise the calculation may
            fail.
        r)r!�intr �dst)r�dt_utc�dt_wallZ
delta_wall�_foldrrr�_fold_statuss

%z_tzinfo._fold_statuscCst|dd�S)Nrr)r)rrrrrr&�sz
_tzinfo._foldcCs�t|t�std��|j|k	r6td��|j�}|dkrZtd��|j�}|dkr~td��||}|r�||7}t|dd�j�}|dkr�td��||S)	a�
        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
        occurence, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.dateime` object.
        z&fromutc() requires a datetime argumentzdt.tzinfo is not selfNz0fromutc() requires a non-None utcoffset() resultz*fromutc() requires a non-None dst() resultrrz;fromutc(): dt.dst gave inconsistent results; cannot convert)�
isinstancer�	TypeErrorr�
ValueErrorr r#r)rrZdtoffZdtdstZdeltarrr�_fromutc�s"

z_tzinfo._fromutccCs1|j|�}|j||�}t|d|�S)a�
        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
        occurance, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.dateime` object.
        r)r+r'r)rrr%r&rrr�fromutc�s
z_tzinfo.fromutcN)	rrrrr!r'r&r+r,rrrrras*rc@s�eZdZdZdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Ze
dd��ZdZdd�Zdd�ZejZdS)�tzrangebasea�
    This is an abstract base class for time zones represented by an annual
    transition into and out of DST. Child classes should implement the following
    methods:

        * ``__init__(self, *args, **kwargs)``
        * ``transitions(self, year)`` - this is expected to return a tuple of
          datetimes representing the DST on and off transitions in standard
          time.

    A fully initialized ``tzrangebase`` subclass should also provide the
    following attributes:
        * ``hasdst``: Boolean whether or not the zone uses DST.
        * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
          representing the respective UTC offsets.
        * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
          abbreviations in DST and STD, respectively.
        * ``_hasdst``: Whether or not the zone has DST.

    ..versionadded:: 2.6.0
    cCstd��dS)Nz%tzrangebase is an abstract base class)�NotImplementedError)rrrr�__init__�sztzrangebase.__init__cCs7|j|�}|dkrdS|r,|jS|jSdS)N)�_isdst�_dst_offset�_std_offset)rr�isdstrrrr �sztzrangebase.utcoffsetcCs4|j|�}|dkrdS|r,|jStSdS)N)r0�_dst_base_offset�ZERO)rrr3rrrr#�sztzrangebase.dstcCs!|j|�r|jS|jSdS)N)r0Z	_dst_abbrZ	_std_abbr)rrrrr�tznamesztzrangebase.tznamec
Cs
t|t�std��|j|k	r6td��|j|j�}|dkre||j|�S|\}}||j8}||j8}||f}|j	dd�}|j
||�}|r�||j}n
||j}t|o�|j
|��}	t|d|	�S)z, Given a datetime in UTC, return local time z&fromutc() requires a datetime argumentzdt.tzinfo is not selfNrr)r(rr)rr*�transitions�yearr r2r�_naive_isdstr1r"r!r)
rrr7�dston�dstoffZutc_transitionsr$r3r%r&rrrr,s$


ztzrangebase.fromutccCsV|js
dS|j|j�\}}|jdd�}||koS||jkSS)a6
        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
        FrN)�hasdstr7r8rr4)rr�start�endrrrr!1s
	ztzrangebase.is_ambiguouscCs�|js
dS|dkrdS|j|j�}|dkr?dS|jdd�}|j||�}|r�|j|�r�|j|�S|SdS)NFr)r<r7r8rr9r!r&)rrr7r3rrrr0Gs	ztzrangebase._isdstcCsj|\}}|jdd�}||krI||koA|kn}n||ko`|kn}|S)Nr)r)rrr7r:r;r3rrrr9\sztzrangebase._naive_isdstcCs|j|jS)N)r1r2)rrrrr4hsztzrangebase._dst_base_offsetNcCs||kS)Nr)r�otherrrr�__ne__nsztzrangebase.__ne__cCsd|jjS)Nz%s(...))�	__class__r)rrrr�__repr__qsztzrangebase.__repr__)rrrrr/r r#rr6r,r!r0r9rr4�__hash__r@rB�object�
__reduce__rrrrr-�s

"r-cCs!|j|jdd|jdS)Ni�Qi@B)ZsecondsZdaysZmicroseconds)Ztdrrr�_total_secondswsrFZ
total_seconds)ZsixrZ	six.movesrrrr�copyr5�__all__r�hasattrrrrr-rFrrrrr�<module>sz�