
    ƺ[Q                     N    d dl mZ d dlmZmZ d dlmZ  G d de      Zd Zd Z	y)	    )division)	timedeltatzinfo)deepcopyc                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	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                     t        j                  |        |dk  rt        d      |dk  r|dz  }t        ||      | _        dt        t        | j                              z   | _        y)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   s      1/usr/lib/python3/dist-packages/pyrfc3339/utils.pyr   zFixedOffset.__init__(   s_    
 	Q;;<<19rMG!*13h'8'GHH    c                     t        d      S )zG
        Return offset for DST.  Always returns timedelta(0).

        r   )r   r   dts     r   dstzFixedOffset.dst6   s    
 |r   c                     | j                   S )z*
        Return offset from UTC.

        )r   r   s     r   	utcoffsetzFixedOffset.utcoffset=   s    
 }}r   c                     | j                   S )z+
        Return name of timezone.

        )r   r   s     r   tznamezFixedOffset.tznameD   s    
 {{r   c                 B    dj                  | j                  d             S )Nz<{0}>)formatr   )r   s    r   __repr__zFixedOffset.__repr__K   s    ~~dkk$/00r   c           	          | j                   }|j                  |      }||t        |       <   | j                  j	                         D ]  \  }}t        ||t        ||              |S )N)	__class____new__id__dict__itemssetattrr   )r   memoclsresultkvs         r   __deepcopy__zFixedOffset.__deepcopy__N   s^    nnS!RXMM'') 	2DAqFAx401	2r   N)
__name__
__module____qualname____doc__r   r   r   r   r!   r.    r   r   r   r      s'    @I1r   r   c                     	 t        t        | j                                     S # t        $ rG | j                  }| j
                  }| j                  }t        t        |dz  |z   |dz  z               cY S w xY w)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

    iQ i@B )introundtotal_secondsAttributeErrordayssecondsmicroseconds)tdr9   r:   r;   s       r   r   r   W   sp    2O5))+,-- Oww**5$,'1\G5KLMNNOs   !$ AA43A4c                     t        t        |       d      \  }}t        t        |      dz        }| dk\  rd}nd}dj	                  |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absr6   floatr    r5   )r   r   r:   r   signs        r   r   r   z   sY     C	ND1NE7E'NR'(GA~&&tSZWFFr   N)

__future__r   datetimer   r   copyr   r   r   r   r3   r   r   <module>rH      s*     & M& M` OFGr   