o
    ¯b8  ã                   @   sN   d Z ddlmZmZmZ ddlmZ ddgZ	G dd„ deƒZ
e
 ddd¡ZdS )	z
Time zone utilities.
é    )ÚdatetimeÚ	timedeltaÚtzinfo)ÚOptionalÚFixedOffsetTimeZoneÚUTCc                	   @   s¢   e Zd ZdZddedee ddfdd„Zeded	e	d
e	dd fdd„ƒZ
ededd fdd„ƒZdee defdd„Zdee defdd„Zdee defdd„ZdS )r   a*  
    Represents a fixed timezone offset (without daylight saving time).

    @ivar name: A L{str} giving the name of this timezone; the name just
        includes how much time this offset represents.

    @ivar offset: A L{TimeDelta} giving the amount of time this timezone is
        offset.
    NÚoffsetÚnameÚreturnc                 C   s   || _ || _dS )zÆ
        Construct a L{FixedOffsetTimeZone} with a fixed offset.

        @param offset: a delta representing the offset from UTC.
        @param name: A name to be given for this timezone.
        N)r   r	   )Úselfr   r	   © r   ú:/usr/lib/python3/dist-packages/twisted/python/_tzhelper.pyÚ__init__   s   
zFixedOffsetTimeZone.__init__ÚsignÚhoursÚminutesc                 C   sL   d|||f }|dkr| }| }n|dkrt d|›�ƒ‚| t||d�|ƒS )a
  
        Construct a L{FixedOffsetTimeZone} from an offset described by sign
        ('+' or '-'), hours, and minutes.

        @note: For protocol compatibility with AMP, this method never uses 'Z'

        @param sign: A string describing the positive or negative-ness of the
            offset.
        @param hours: The number of hours in the offset.
        @param minutes: The number of minutes in the offset

        @return: A time zone with the given offset, and a name describing the
            offset.
        z%s%02i:%02iú-ú+zInvalid sign for timezone )r   r   )Ú
ValueErrorÚ	TimeDelta)Úclsr   r   r   r	   r   r   r   ÚfromSignHoursMinutes'   s   z(FixedOffsetTimeZone.fromSignHoursMinutesÚ	timeStampc                 C   s   t  |¡t  |¡ }| |ƒS )zŒ
        Create a time zone with a fixed offset corresponding to a time stamp in
        the system's locally configured time zone.
        )ÚDateTimeÚfromtimestampÚutcfromtimestamp)r   r   r   r   r   r   ÚfromLocalTimeStampA   s   ÿz&FixedOffsetTimeZone.fromLocalTimeStampÚdtc                 C   s   | j S )z>
        Return the given timezone's offset from UTC.
        )r   ©r   r   r   r   r   Ú	utcoffsetL   s   zFixedOffsetTimeZone.utcoffsetc                 C   s   t dƒS )zs
        Return a zero L{TimeDelta} for the daylight saving time
        offset, since there is never one.
        r   )r   r   r   r   r   ÚdstR   s   zFixedOffsetTimeZone.dstc                 C   s&   | j dur| j S t d| ¡}| d¡S )z;
        Return a string describing this timezone.
        Nr   zUTC%z)r	   r   r   Ústrftimer   r   r   r   ÚtznameY   s   

zFixedOffsetTimeZone.tzname)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   ÚclassmethodÚintr   Úfloatr   r   r   r    r"   r   r   r   r   r      s$    

ÿÿÿþ
r   N)r&   r   r   r   r   r   ÚTZInfoÚtypingr   Ú__all__r   r   r   r   r   r   r   Ú<module>   s   þR