V!\c@sydZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl Z ddl m Z ddl m Z ddlmZmZddlmZmZdd lmZdd lmZmZdd lmZydd lmZmZWnek r/eZZnXdd lmZejdZ ejj!dZ"e"j#Z$e j%edej&fdYZ'e j%edej&fdYZ(defdYZ)de*fdYZ+de*fdYZ,defdYZ-defdYZ.e j%ede.fdYZ/de*fd YZ0d!efd"YZ1d#e*fd$YZ2ej3d%krd&d'gZ4d(d)d*d+gZ5n gZ4gZ5d,Z6e6Z7[6ed-Z8ed.Z9d/Z:d0Z;ej<d1d2fkr.d3Z=n d4Z=ydd5l>m?Z@Wn'ek rtd6e*fd7YZ@nXdS(8s This module offers timezone implementations subclassing the abstract :py:class:`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. iN(t OrderedDict(t string_types(t_threadi(ttzname_in_python2t_tzinfo(t tzrangebasetenfold(t_validate_fromutc_inputs(t _TzSingletont_TzOffsetFactory(t _TzStrFactory(ttzwint tzwinlocal(twarnittzutccBsqeZdZdZdZedZdZedZ dZ d Z dZ dZejZRS( s This is a tzinfo object that represents the UTC time zone. **Examples:** .. doctest:: >>> from datetime import * >>> from dateutil.tz import * >>> datetime.now() datetime.datetime(2003, 9, 27, 9, 40, 1, 521290) >>> datetime.now(tzutc()) datetime.datetime(2003, 9, 27, 12, 40, 12, 156379, tzinfo=tzutc()) >>> datetime.now(tzutc()).tzname() 'UTC' .. versionchanged:: 2.7.0 ``tzutc()`` is now a singleton, so the result of ``tzutc()`` will always return the same object. .. doctest:: >>> from dateutil.tz import tzutc, UTC >>> tzutc() is tzutc() True >>> tzutc() is UTC True cCstS(N(tZERO(tselftdt((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt utcoffsetJscCstS(N(R(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pytdstMscCsdS(NtUTC((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyttznamePscCstS(s6 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 (tFalse(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt is_ambiguousTscCs|S(s Fast track version of fromutc() returns the original ``dt`` object for any valid :py:class:`datetime.datetime` object. ((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pytfromutcdscCsDt|ttfstSt|tpCt|toC|jtkS(N(t isinstanceRttzoffsettNotImplementedt_offsetR(Rtother((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt__eq__lscCs ||k S(N((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt__ne__uscCsd|jjS(Ns%s()(t __class__t__name__(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt__repr__xsN(R!t __module__t__doc__RRRRRRRRtNonet__hash__RR"tobjectt __reduce__(((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR)s       RcBszeZdZdZdZdZedZedZ dZ dZ d Z dZd ZejZRS( s1 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). cCsR||_y|j}Wnttfk r2nXtjdt||_dS(Ntseconds(t_namet total_secondst TypeErrortAttributeErrortdatetimet timedeltat_get_supported_offsetR(Rtnametoffset((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt__init__s  cCs|jS(N(R(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCstS(N(R(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs|jS(N(R*(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs ||jS(N(R(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCstS(s4 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 (R(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRs cCs#t|tstS|j|jkS(N(RRRR(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs ||k S(N((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs/d|jjt|jt|jjfS(Ns %s(%s, %s)(R R!treprR*tintRR+(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR"s  N(R!R#R$R3RRRRRRRRR%R&RR"R'R((((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR~s       ttzlocalcBseZdZdZdZdZedZdZdZ e dZ dZ d Zd Zd ZejZRS( sR A :class:`tzinfo` subclass built around the ``time`` timezone functions. cCstt|jtjdtj |_tjrQtjdtj |_ n |j|_ |j |j|_ t |j |_ ttj|_dS(NR)(tsuperR6R3R.R/ttimettimezonet _std_offsettdaylighttaltzonet _dst_offsett _dst_savedtboolt_hasdstttupleRt_tznames(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3s  cCs:|dkr|jrdS|j|r/|jS|jSdS(N(R%R@t_isdstR=R:(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRs cCs>|dkr|jrdS|j|r6|j|jStSdS(N(R%R@RCR=R:R(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRs cCs|j|j|S(N(RBRC(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs0|j|}| o/||j||jkS(s6 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 (t _naive_is_dstR>(RRt naive_dst((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs#t|}tj|tjjS(N(t_datetime_to_timestampR8t localtimeR9ttm_isdst(RRt timestamp((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRDs cCsb|js tS|j|}t|dd}|j|r^|dk rW|j| StSn|S(Ntfold(R@RRDtgetattrR%Rt_foldtTrue(RRt fold_naivetdstvalRJ((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRCs  cCst|tr1|j|jko0|j|jkSt|trp|j oo|jdddhkoo|jtkSt|tr|j o|jd|j ko|j|j kSt SdS(NiRtGMT( RR6R:R=RR@RBRRR*RR(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR(s   cCs ||k S(N((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR9scCsd|jjS(Ns%s()(R R!(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR"<sN(R!R#R$R3RRRRRRDRMRCRR%R&RR"R'R((((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR6s    (   t_ttinfocBs_eZdddddddgZdZdZd Zd Zd Zd Z d Z RS(R2tdeltatisdsttabbrtisstdtisgmtt dstoffsetcCs(x!|jD]}t||dq WdS(N(t __slots__tsetattrR%(Rtattr((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3FscCsrg}xL|jD]A}t||}|dk r|jd|t|fqqWd|jjdj|fS(Ns%s=%ss%s(%s)s, (RXRKR%tappendR4R R!tjoin(RtlRZtvalue((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR"Js  $cCst|tstS|j|jko|j|jko|j|jko|j|jko|j|jko|j|jko|j |j kS(N( RRQRR2RRRSRTRURVRW(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRRscCs ||k S(N((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR`scCs4i}x'|jD]}t||d||`_ for more information. Time zone files can be compiled from the `IANA Time Zone database files `_ with the `zic time zone compiler `_ .. note:: Only construct a ``tzfile`` directly if you have a specific timezone file on disk that you want to read into a Python ``tzinfo`` object. If you want to get a ``tzfile`` representing a specific IANA zone, (e.g. ``'America/New_York'``), you should call :func:`dateutil.tz.gettz` with the zone identifier. **Examples:** Using the US Eastern time zone as an example, we can see that a ``tzfile`` provides time zone information for the standard Daylight Saving offsets: .. testsetup:: tzfile from dateutil.tz import gettz from datetime import datetime .. doctest:: tzfile >>> NYC = gettz('America/New_York') >>> NYC tzfile('/usr/share/zoneinfo/America/New_York') >>> print(datetime(2016, 1, 3, tzinfo=NYC)) # EST 2016-01-03 00:00:00-05:00 >>> print(datetime(2016, 7, 7, tzinfo=NYC)) # EDT 2016-07-07 00:00:00-04:00 The ``tzfile`` structure contains a fully history of the time zone, so historical dates will also have the right offsets. For example, before the adoption of the UTC standards, New York used local solar mean time: .. doctest:: tzfile >>> print(datetime(1901, 4, 12, tzinfo=NYC)) # LMT 1901-04-12 00:00:00-04:56 And during World War II, New York was on "Eastern War Time", which was a state of permanent daylight saving time: .. doctest:: tzfile >>> print(datetime(1944, 2, 7, tzinfo=NYC)) # EWT 1944-02-07 00:00:00-04:00 cCstt|jt}t|trI||_t|d}t}nE|dk ra||_n-t |dr|j |_nt ||_|dk r|st |}n|}|j|}WdQX|j|ndS(NtrbR1(R7RnR3RRRt _filenametopenRMR%thasattrR1R4t _nullcontextt _read_tzfilet _set_tzdata(Rtfileobjtfilenametfile_opened_heret file_streamttzobj((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3s"      cCs5x.tjD]#}t|d|t||q WdS(s= Set the time zone data of this object from a _tzfile object t_N(RbRkRYRK(RRzRZ((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRuscCs6t}|jdjdkr3tdn|jdtjd|jd\}}}}}}|rttjd||j|d|_n g|_|rtjd||j||_n g|_g} x6t |D](} | j tjd |jd qW|j|j} |rS|j |d t j n|r{tjd ||j|} n|rtjd ||j|} ng|_xt |D]} | | \}}}t|}t}||_tjd |_tjd||_||_| || jd|!|_|| koU| | d k|_|| kot| | d k|_|jj |qWg|jD]}|j|^q|_d|_d|_d|_|jr|js|jd |_|_qxt |dddD]h} |j| }|j rE|j rE||_n|j rd|jrd||_n|jr|jrPqqW|jr|j r|j|_nx:|jD]}|js||_PqqW|jd |_nd}d}d}d}g|_ xt!|jD]\} }|j}d }|dk r|jr|sQ||}n| rg|rg|}ntjd||_|}qn||}|}|dk r||kr|j|kr|}n|j}|}|}|j j |j| |qWt"|j|_t"|j |_ t"|j|_|S(NitTZifsmagic not foundis>6lis>%dls>%dBs>lbbiis>%dbiR)tii(#Rbtreadtdecodet ValueErrortstructtunpacktlistRdRetrangeR[tseektostSEEK_CURRfR0RQR2R.R/RWRRRStfindRTRURVR%RgRhRiRjRct enumerateRA(RRvtoutt ttisgmtcntt ttisstdcnttleapcntttimecntttypecnttcharcnttttinfotiRTRURVtgmtoffRStabbrindtttitidxtlastdstt lastoffsett lastdstoffsettlastbaseoffsetR2RWt baseoffsett adjustment((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRts  -    &          &                      cCsK|js dSt|}|r(|jn|j}tj||}|dS(Ni(t _trans_listR%RFt_trans_list_utctbisectt bisect_right(RRtin_utcRIRcR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt_find_last_transitions   cCsJ|dks%|dt|jkr,|jS|dkr?|jS|j|S(Nii(R%tlenRt _ttinfo_stdt_ttinfo_beforet _trans_idx(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt _get_ttinfos % cCs|j|}|j|S(N(t_resolve_ambiguous_timeR(RRR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt _find_ttinfoscCst|tjs!tdn|j|k r?tdn|j|dt}|j|}|tjd|j }|j |d|}t |dt |S(s The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`. :param dt: A :py:class:`datetime.datetime` object. :raises TypeError: Raised if ``dt`` is not a :py:class:`datetime.datetime` object. :raises ValueError: Raised if this is called with a ``dt`` which does not have this ``tzinfo`` attached. :return: Returns a :py:class:`datetime.datetime` object representing the wall time in ``self``'s time zone. s&fromutc() requires a datetime argumentsdt.tzinfo is not selfRR)RRJ( RR.R,ttzinfoRRRMRR/R2RRR5(RRRRtdt_outRJ((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs|dkr|j|}nt|}|j|}|dksQ|dkrUtS|j|dj|j}|j|}|||kS(s6 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 iiN(R%RRFRRR2R(RRRRIRtodttt((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRs   cCsa|j|}|j|}|dks6|dkr:|St| oS|j||}||S(Ni(RRLR%R5R(RRRRLt idx_offset((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR"s cCs-|dkrdS|jstS|j|jS(N(R%RRRRR(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR/s   cCs@|dkrdS|jstS|j|}|js9tS|jS(N(R%t _ttinfo_dstRRRSRW(RRR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR8s   cCs*|j s|dkrdS|j|jS(N(RR%RRT(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRHscCsGt|tstS|j|jkoF|j|jkoF|j|jkS(N(RRnRRRt _ttinfo_list(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRNs cCs ||k S(N((RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRWscCsd|jjt|jfS(Ns%s(%s)(R R!R4Rp(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR"ZscCs |jdS(N(t __reduce_ex__R%(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR(]scCs|jd|jf|jfS(N(R R%Rpt__dict__(Rtprotocol((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR`sN(R!R#R$R%R3RuRtRRRRRRRRRRRRR&RR"R(R(((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRn|s&F     $      ttzrangecBsGeZdZddddddZdZdZedZRS(s[ The ``tzrange`` object is a time zone specified by a set of offsets and abbreviations, equivalent to the way the ``TZ`` variable can be specified in POSIX-like systems, but using Python delta objects to specify DST start, end and offsets. :param stdabbr: The abbreviation for standard time (e.g. ``'EST'``). :param stdoffset: An integer or :class:`datetime.timedelta` object or equivalent specifying the base offset from UTC. If unspecified, +00:00 is used. :param dstabbr: The abbreviation for DST / "Summer" time (e.g. ``'EDT'``). If specified, with no other DST information, DST is assumed to occur and the default behavior or ``dstoffset``, ``start`` and ``end`` is used. If unspecified and no other DST information is specified, it is assumed that this zone has no DST. If this is unspecified and other DST information is *is* specified, DST occurs in the zone but the time zone abbreviation is left unchanged. :param dstoffset: A an integer or :class:`datetime.timedelta` object or equivalent specifying the UTC offset during DST. If unspecified and any other DST information is specified, it is assumed to be the STD offset +1 hour. :param start: A :class:`relativedelta.relativedelta` object or equivalent specifying the time and time of year that daylight savings time starts. To specify, for example, that DST starts at 2AM on the 2nd Sunday in March, pass: ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))`` If unspecified and any other DST information is specified, the default value is 2 AM on the first Sunday in April. :param end: A :class:`relativedelta.relativedelta` object or equivalent representing the time and time of year that daylight savings time ends, with the same specification method as in ``start``. One note is that this should point to the first time in the *standard* zone, so if a transition occurs at 2AM in the DST zone and the clocks are set back 1 hour to 1AM, set the ``hours`` parameter to +1. **Examples:** .. testsetup:: tzrange from dateutil.tz import tzrange, tzstr .. doctest:: tzrange >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT") True >>> from dateutil.relativedelta import * >>> range1 = tzrange("EST", -18000, "EDT") >>> range2 = tzrange("EST", -18000, "EDT", -14400, ... relativedelta(hours=+2, month=4, day=1, ... weekday=SU(+1)), ... relativedelta(hours=+1, month=10, day=31, ... weekday=SU(-1))) >>> tzstr('EST5EDT') == range1 == range2 True c Csddlma||_||_y|j}Wnttfk rKnXy|j}Wnttfk runX|dk rtj d||_ n t |_ |dk rtj d||_ n;|r|dk r|j tj dd |_ n t |_ |rI|dkrItjdd ddd dd tj d |_n ||_|r|dkrtjdd dd d d d tj d|_n ||_|j |j |_t|j|_dS( Ni(t relativedeltaR)thoursiitmonthitdaytweekdayi i(tdateutilRt _std_abbrt _dst_abbrR+R,R-R%R.R/R:RR=tSUt _start_deltat _end_deltat_dst_base_offset_R?thasdst(Rtstdabbrt stdoffsettdstabbrRWtstarttend((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3s:        ,  + cCsF|js dStj|dd}||j}||j}||fS(s For a given year, get the DST on and off transition times, expressed always on the standard time side. For zones with no transitions, this function returns ``None``. :param year: The year whose transitions you would like to query. :return: Returns a :class:`tuple` of :class:`datetime.datetime` objects, ``(dston, dstoff)`` for zones with an annual DST transition, or ``None`` for fixed offset zones. iN(RR%R.RR(Rtyeart base_yearRR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt transitionss    cCs}t|tstS|j|jko||j|jko||j|jko||j|jko||j|jko||j|jkS(N( RRRRRR:R=RR(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs|jS(N(R(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt_dst_base_offsetsN( R!R#R$R%R3RRtpropertyR(((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRdsJ-  ttzstrcBs/eZdZedZddZdZRS(s ``tzstr`` objects are time zone objects specified by a time-zone string as it would be passed to a ``TZ`` variable on POSIX-style systems (see the `GNU C Library: TZ Variable`_ for more details). There is one notable exception, which is that POSIX-style time zones use an inverted offset format, so normally ``GMT+3`` would be parsed as an offset 3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX behavior, pass a ``True`` value to ``posix_offset``. The :class:`tzrange` object provides the same functionality, but is specified using :class:`relativedelta.relativedelta` objects. rather than strings. :param s: A time zone string in ``TZ`` variable format. This can be a :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x: :class:`unicode`) or a stream emitting unicode characters (e.g. :class:`StringIO`). :param posix_offset: Optional. If set to ``True``, interpret strings such as ``GMT+3`` or ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the POSIX standard. .. caution:: Prior to version 2.7.0, this function also supported time zones in the format: * ``EST5EDT,4,0,6,7200,10,0,26,7200,3600`` * ``EST5EDT,4,1,0,7200,10,-1,0,7200,3600`` This format is non-standard and has been deprecated; this function will raise a :class:`DeprecatedTZFormatWarning` until support is removed in a future version. .. _`GNU C Library: TZ Variable`: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html c Csddlma||_tj|}|dks=|jrLtdn|jd krt| rt|j d9_ nt j ||j|j |j |j dtdt|j sd|_d|_n<|j|j|_|jr|j|jdd |_nt|j|_dS( Ni(t_parsersunknown string formatRPRRRtisendi(sGMTsUTC(tdateutil.parserRtparsert_st_parsetzR%tany_unused_tokensRRRRR3RRWRRRt_deltaRRR?R(Rtst posix_offsettres((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR31s"      icCsddlm}i}|jdk r|j|d<|jdk r|j|j|j|d<|jdkryd|d|jdk r|j|d (R4R(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR"s( R!R#R3RRRRRRR"R'R((((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRs -    ttzicalcBsGeZdZdZdZddZdZdZdZ RS(s[ This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure as set out in `RFC 5545`_ Section 4.6.5 into one or more `tzinfo` objects. :param `fileobj`: A file or stream in iCalendar format, which should be UTF-8 encoded with CRLF endings. .. _`RFC 5545`: https://tools.ietf.org/html/rfc5545 cCsddlmat|tr:||_t|d}n't|dt||_t|}i|_ |}|j |j WdQXdS(Ni(RtrR1( RRRRRRqRKR4Rst_vtzt _parse_rfcR~(RRvtfobj((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3s    cCst|jjS(s? Retrieves the available time zones as a list. (RRtkeys(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRscCs||dkrlt|jdkr0tdn$t|jdkrTtdntt|j}n|jj|S(s Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``. :param tzid: If there is exactly one time zone available, omitting ``tzid`` or passing :py:const:`None` value returns it. Otherwise a valid key (which can be retrieved from :func:`keys`) is required. :raises ValueError: Raised if ``tzid`` is not specified but there are either more or fewer than 1 zone defined. :returns: Returns either a :py:class:`datetime.tzinfo` object representing the relevant time zone or :py:const:`None` if the ``tzid`` was not found. isno timezones definedis more than one timezone availableN(R%RRRtnexttiterRl(RR((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRls cCs|j}|s!tdn|dd krYdd f|ddk}|d}nd }t|dkrt|d d t|dd |St|d krt|d d t|dd!d t|d|Std |dS(Ns empty offsetit+t-iiiiii<isinvalid offset: (RR(tstripRRR5(RRtsignal((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt _parse_offsets  (9c Cs|j}|s!tdnd}x~|t|kr||j}|s\||=q*|dkr|ddkr||dc|d7<||=q*|d7}q*Wd}g}t}d}x|D]}|sqn|jdd\} } | jd} | stdn| dj} | d} |rz| dkr| d,krPntd | | }t} d} d}g}d}q| d kr| d kr|rtd|n|stdn|stdnt|||j |>> gettz() tzfile('/etc/localtime') This function is also the preferred way to map IANA tz database keys to :class:`tzfile` objects: .. code-block:: python3 >>> gettz('Pacific/Kiritimati') tzfile('/usr/share/zoneinfo/Pacific/Kiritimati') On Windows, the standard is extended to include the Windows-specific zone names provided by the operating system: .. code-block:: python3 >>> gettz('Egypt Standard Time') tzwin('Egypt Standard Time') Passing a GNU ``TZ`` style string time zone specification returns a :class:`tzstr` object: .. code-block:: python3 >>> gettz('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3') tzstr('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3') :param name: A time zone name (IANA, or, on Windows, Windows keys), location of a ``tzfile(5)`` zoneinfo file or ``TZ`` variable style time zone specifier. An empty string, no argument or ``None`` is interpreted as local time. :return: Returns an instance of one of ``dateutil``'s :py:class:`tzinfo` subclasses. .. versionchanged:: 2.7.0 After version 2.7.0, any two calls to ``gettz`` using the same input strings will return the same object: .. code-block:: python3 >>> tz.gettz('America/Chicago') is tz.gettz('America/Chicago') True In addition to improving performance, this ensures that `"same zone" semantics`_ are used for datetimes in the same zone. .. _`TZ variable`: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html .. _`"same zone" semantics`: https://blog.ganssle.io/articles/2018/02/aware-datetime-arithmetic.html cSs7tj|_d|_t|_tj|_dS(Ni( tweakreftWeakValueDictionaryt_GettzFunc__instancest_GettzFunc__strong_cache_sizeRt_GettzFunc__strong_cacheRRR(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3s  cs|j|jj|d}|dkr{|jd|}|dkpat|pa|dkst||j|>> from dateutil import tz >>> from datetime import datetime >>> NYC = tz.gettz('America/New_York') >>> print(tz.resolve_imaginary(datetime(2017, 3, 12, 2, 30, tzinfo=NYC))) 2017-03-12 03:30:00-04:00 >>> KIR = tz.gettz('Pacific/Kiritimati') >>> print(tz.resolve_imaginary(datetime(1995, 1, 1, 12, 30, tzinfo=KIR))) 1995-01-02 12:30:00+14:00 As a note, :func:`datetime.astimezone` is guaranteed to produce a valid, existing datetime, so a round-trip to and from UTC is sufficient to get an extant datetime, however, this generally "falls back" to an earlier time rather than falling forward to the STD side (though no guarantees are made about this behavior). :param dt: A :class:`datetime.datetime` which may or may not exist. :return: Returns an existing :class:`datetime.datetime`. If ``dt`` was not imaginary, the datetime returned is guaranteed to be the same object passed to the function. .. versionadded:: 2.7.0 RiN(RR%RSR.R/R(Rt curr_offsett old_offset((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pytresolve_imaginarys $cCs|jddtjS(s Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds since January 1, 1970, ignoring the time zone. RN(RR%tEPOCHR+(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRFsiicCs|S(N((t second_offset((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR0 scCs|}d|dd}|S(Ni<i((R_R\tcalculated_offset((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR0s(t nullcontextRscBs)eZdZdZdZdZRS(sj Class for wrapping contexts so that they are passed through in a with statement. cCs ||_dS(N(tcontext(RRb((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyR3#scCs|jS(N(Rb(R((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt __enter__&scOsdS(N((targsRm((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt__exit__)s(R!R#R$R3RcRe(((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyRss  (AR$R.RR8tsysRRR-t collectionsRtsixRt six.movesRt_commonRRRRRt _factoriesRR R twinR R t ImportErrorR%twarningsR R/RtutcfromtimestampR^t toordinalt EPOCHORDINALt add_metaclassRRRR6R'RQRbRnRRRRRtplatformRARDRPtgettzRSRZR]RFt version_infoR0tcontextmanagerRaRs(((s9/tmp/pip-install-usGedi/python-dateutil/dateutil/tz/tz.pyt sz          TD- w V    " . .