U
    ÈZjQ  ã                   @   sL   d dl mZ d dlmZmZ d dlmZ G dd„ deƒZdd„ Zdd	„ Z	d
S )é    )Údivision)Ú	timedeltaÚtzinfo)Údeepcopyc                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚFixedOffseta™  
    Represent a timezone with a fixed offset from UTC and no adjustment for
    DST.

    >>> FixedOffset(4,0)
    <UTC+04:00>
    >>> FixedOffset(-4,0)
    <UTC-04:00>
    >>> FixedOffset(4,30)
    <UTC+04:30>

    >>> tz = FixedOffset(-5,0)
    >>> tz.dst(None)
    datetime.timedelta(0)

    The class tries to do the right thing with the sign
    of the time zone offset:

    >>> FixedOffset(-9,30)
    <UTC-09:30>
    >>> FixedOffset(-9,-30)
    Traceback (most recent call last):
    ...
    ValueError: minutes must not be negative

    Offsets must thus be normalized so that the minute value is positive:

    >>> FixedOffset(-8,30)
    <UTC-08:30>

    c                 C   sP   t  | ¡ |dk rtdƒ‚|dk r*|d9 }t||d�| _dtt| jƒƒ | _dS )zK
        Create a new FixedOffset instance with the given offset.

        r   zminutes must not be negativeéÿÿÿÿ)ÚhoursÚminutesÚUTCN)r   Ú__init__Ú
ValueErrorr   Ú_FixedOffset__offsetÚtimezoneÚtimedelta_secondsÚ_FixedOffset__name)Úselfr   r	   © r   úR/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/pyrfc3339/utils.pyr   (   s    
ÿzFixedOffset.__init__c                 C   s   t dƒS )zG
        Return offset for DST.  Always returns timedelta(0).

        r   )r   ©r   Údtr   r   r   Údst6   s    zFixedOffset.dstc                 C   s   | j S )z*
        Return offset from UTC.

        )r   r   r   r   r   Ú	utcoffset=   s    zFixedOffset.utcoffsetc                 C   s   | j S )z+
        Return name of timezone.

        )r   r   r   r   r   ÚtznameD   s    zFixedOffset.tznamec                 C   s   d  |  d ¡¡S )Nz<{0}>)Úformatr   )r   r   r   r   Ú__repr__K   s    zFixedOffset.__repr__c                 C   sF   | j }| |¡}||t| ƒ< | j ¡ D ]\}}t||t||ƒƒ q&|S )N)Ú	__class__Ú__new__ÚidÚ__dict__ÚitemsÚsetattrr   )r   ÚmemoÚclsÚresultÚkÚvr   r   r   Ú__deepcopy__N   s    
zFixedOffset.__deepcopy__N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r&   r   r   r   r   r      s    r   c                 C   sZ   zt t|  ¡ ƒƒW S  tk
rT   | j}| j}| j}t t|d | |d  ƒƒ Y S X dS )a•  
    Return the offset stored by a :class:`datetime.timedelta` object as an
    integer number of seconds.  Microseconds, if present, are rounded to
    the nearest second.

    Delegates to
    :meth:`timedelta.total_seconds() <datetime.timedelta.total_seconds()>`
    if available.

    >>> timedelta_seconds(timedelta(hours=1))
    3600
    >>> timedelta_seconds(timedelta(hours=-1))
    -3600
    >>> timedelta_seconds(timedelta(hours=1, minutes=30))
    5400
    >>> timedelta_seconds(timedelta(hours=1, minutes=30,
    ... microseconds=300000))
    5400
    >>> timedelta_seconds(timedelta(hours=1, minutes=30,
    ...	microseconds=900000))
    5401

    i€Q i@B N)ÚintÚroundÚtotal_secondsÚAttributeErrorÚdaysÚsecondsÚmicroseconds)Útdr/   r0   r1   r   r   r   r   W   s    r   c                 C   sJ   t t| ƒdƒ\}}tt|ƒd ƒ}| dkr0d}nd}d |t|ƒt|ƒ¡S )zä
    Return a string representing the timezone offset.
    Remaining seconds are rounded to the nearest minute.

    >>> timezone(3600)
    '+01:00'
    >>> timezone(5400)
    '+01:30'
    >>> timezone(-28800)
    '-08:00'

    i  é<   r   ú+ú-z{0}{1:02d}:{2:02d})ÚdivmodÚabsr,   Úfloatr   r+   )r   r   r0   r	   Úsignr   r   r   r   z   s    r   N)
Ú
__future__r   Údatetimer   r   Úcopyr   r   r   r   r   r   r   r   Ú<module>   s
   P#