ó
Æº[c           @   sb   d  d l  m Z d  d l m Z m Z d  d l m Z d e f d „  ƒ  YZ d „  Z d „  Z	 d S(	   iÿÿÿÿ(   t   division(   t	   timedeltat   tzinfo(   t   deepcopyt   FixedOffsetc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s™  
    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   sy   t  j |  ƒ | d k  r( t d ƒ ‚ n  | d k  rA | d 9} n  t d | d | ƒ |  _ d t t |  j ƒ ƒ |  _ d S(   sK   
        Create a new FixedOffset instance with the given offset.

        i    s   minutes must not be negativeiÿÿÿÿt   hourst   minutest   UTCN(   R   t   __init__t
   ValueErrorR   t   _FixedOffset__offsett   timezonet   timedelta_secondst   _FixedOffset__name(   t   selfR   R   (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyR   (   s    c         C   s
   t  d ƒ S(   sG   
        Return offset for DST.  Always returns timedelta(0).

        i    (   R   (   R   t   dt(    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyt   dst6   s    c         C   s   |  j  S(   s*   
        Return offset from UTC.

        (   R
   (   R   R   (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyt	   utcoffset=   s    c         C   s   |  j  S(   s+   
        Return name of timezone.

        (   R   (   R   R   (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyt   tznameD   s    c         C   s   d j  |  j d  ƒ ƒ S(   Ns   <{0}>(   t   formatR   t   None(   R   (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyt   __repr__K   s    c         C   se   |  j  } | j | ƒ } | | t |  ƒ <x6 |  j j ƒ  D]% \ } } t | | t | | ƒ ƒ q8 W| S(   N(   t	   __class__t   __new__t   idt   __dict__t   itemst   setattrR   (   R   t   memot   clst   resultt   kt   v(    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyt   __deepcopy__N   s    	(	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R!   (    (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyR      s   					c         C   sj   y t  t |  j ƒ  ƒ ƒ SWnI t k
 re |  j } |  j } |  j } t  t | d | | d ƒ ƒ SXd S(   s•  
    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(   t   intt   roundt   total_secondst   AttributeErrort   dayst   secondst   microseconds(   t   tdR)   R*   R+   (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyR   W   s    			c         C   sk   t  t |  ƒ d ƒ \ } } t t | ƒ d ƒ } |  d k rF d } n d } d j | t | ƒ t | ƒ ƒ S(   sä   
    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  i<   i    t   +t   -s   {0}{1:02d}:{2:02d}(   t   divmodt   absR&   t   floatR   R%   (   R   R   R*   R   t   sign(    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyR   z   s    	N(
   t
   __future__R    t   datetimeR   R   t   copyR   R   R   R   (    (    (    s3   /usr/lib/python2.7/site-packages/pyrfc3339/utils.pyt   <module>   s
   P	#