← Back
Editing: _tzhelper.cpython-38.pyc
U W[x � @ sB d Z ddlmZmZmZ ddgZG dd� de�Ze�ddd�ZdS )z Time zone utilities. � )�datetime� timedelta�tzinfo�FixedOffsetTimeZone�UTCc @ sJ e Zd ZdZddd�Zedd� �Zedd� �Zd d � Zdd� Z d d� Z dS )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. Nc C s || _ || _dS )a Construct a L{FixedOffsetTimeZone} with a fixed offset. @param offset: a delta representing the offset from UTC. @type offset: L{timedelta} @param name: A name to be given for this timezone. @type name: L{str} or L{None} N)�offset�name)�selfr r � r �:/usr/lib/python3/dist-packages/twisted/python/_tzhelper.py�__init__ s zFixedOffsetTimeZone.__init__c C sL d|||f }|dkr$| }| }n|dkr:t d|f ��| t||d�|�S )am 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. @type hours: L{int} @param minutes: The number of minutes in the offset @type minutes: L{int} @return: A time zone with the given offset, and a name describing the offset. @rtype: L{FixedOffsetTimeZone} z%s%02i:%02i�-�+zInvalid sign for timezone %r)�hours�minutes)� ValueErrorr )�clsZsignr r r r r r �fromSignHoursMinutes+ s z(FixedOffsetTimeZone.fromSignHoursMinutesc C s t �|�t �|� }| |�S )a Create a time zone with a fixed offset corresponding to a time stamp in the system's locally configured time zone. @param timeStamp: a time stamp @type timeStamp: L{int} @return: a time zone @rtype: L{FixedOffsetTimeZone} )r � fromtimestampZutcfromtimestamp)r Z timeStampr r r r �fromLocalTimeStampI s ��z&FixedOffsetTimeZone.fromLocalTimeStampc C s | j S )z9 Return this timezone's offset from UTC. )r �r Zdtr r r � utcoffset\ s zFixedOffsetTimeZone.utcoffsetc C s t d�S )z| Return a zero C{datetime.timedelta} for the daylight saving time offset, since there is never one. r )r r r r r �dstc s zFixedOffsetTimeZone.dstc C s&