3 6cY @ s d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m Z mZmZ ddl m Z mZ ddl mZ yddlmZmZ W n ek r d ZZY nX ejdZejjdZej ZG d d d ejZG dd dejZG d d deZG dd deZG dd deZ G dd deZ!G dd de Z"G dd de"Z#G dd deZ$G dd deZ%G dd deZ&ej'dkrd d!gZ(d"d#d$d%gZ)ng Z(g Z)d0d&d'Z*d1d(d)Z+d2d*d+Z,d,d- Z-G d.d/ d/eZ.dS )3a{ This module offers timezone implementations subclassing the abstract :py:`datetime.tzinfo` type. There are classes to handle tzfile format files (usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, etc), TZ environment string (in all known formats), given ranges (with help from relative deltas), local machine timezone, fixed offset timezone, and UTC timezone. N)string_types )tzname_in_python2_tzinfo_total_seconds)tzrangebaseenfold)_validate_fromutc_inputs)tzwin tzwinlocalc @ sb e Zd ZdZdd Zdd Zedd Zdd Ze d d Z dd ZdZdd Z dd ZejZdS )tzutczD This is a tzinfo object that represents the UTC time zone. c C s t S )N)ZERO)selfdt r /usr/lib/python3.6/tz.py utcoffset$ s ztzutc.utcoffsetc C s t S )N)r )r r r r r dst' s z tzutc.dstc C s dS )NUTCr )r r r r r tzname* s ztzutc.tznamec C s dS )a6 Whether or not the "wall time" of a given datetime is ambiguous in this zone. :param dt: A :py:class:`datetime.datetime`, naive or time zone aware. :return: Returns ``True`` if ambiguous, ``False`` otherwise. .. versionadded:: 2.6.0 Fr )r r r r r is_ambiguous. s ztzutc.is_ambiguousc C s |S )z Fast track version of fromutc() returns the original ``dt`` object for any valid :py:class:`datetime.datetime` object. r )r r r r r fromutc> s z tzutc.fromutcc C s0 t |ttfstS t |tp.t |to.|jtkS )N) isinstancer tzoffsetNotImplemented_offsetr )r otherr r r __eq__F s ztzutc.__eq__Nc C s | |k S )Nr )r r r r r __ne__O s ztzutc.__ne__c C s d| j j S )Nz%s()) __class____name__)r r r r __repr__R s ztzutc.__repr__)r __module____qualname____doc__r r r r r r r r __hash__r r! object __reduce__r r r r r s r c @ sj e Zd ZdZdd Zdd Zdd Zedd Ze d d Z dd Zdd ZdZ dd Zdd ZejZdS )r a1 A simple class for representing a fixed offset from UTC. :param name: The timezone name, to be returned when ``tzname()`` is called. :param offset: The time zone offset in seconds, or (since version 2.6.0, represented as a :py:class:`datetime.timedelta` object. c C s> || _ yt|}W n ttfk r* Y nX tj|d| _d S )N)seconds)_namer TypeErrorAttributeErrordatetime timedeltar )r nameoffsetr r r __init__c s ztzoffset.__init__c C s | j S )N)r )r r r r r r m s ztzoffset.utcoffsetc C s t S )N)r )r r r r r r p s ztzoffset.dstc C s | j S )N)r) )r r r r r r s s ztzoffset.tznamec C s || j S )N)r )r r r r r r w s ztzoffset.fromutcc C s dS )a6 Whether or not the "wall time" of a given datetime is ambiguous in this zone. :param dt: A :py:class:`datetime.datetime`, naive or time zone aware. :return: Returns ``True`` if ambiguous, ``False`` otherwise. .. versionadded:: 2.6.0 Fr )r r r r r r { s ztzoffset.is_ambiguousc C s t |tstS | j|jkS )N)r r r r )r r r r r r s ztzoffset.__eq__Nc C s | |k S )Nr )r r r r r r s ztzoffset.__ne__c C s" d| j jt| jtt| jf S )Nz %s(%s, %s))r r reprr) intr r )r r r r r! s ztzoffset.__repr__)r r" r# r$ r0 r r r r r r r r r% r r! r&