ee[c@sdZddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z ddl mZmZddl mZdd lmZmZdd lmZydd lmZmZWnek reZZnXejd Zejjd ZejZej ed ej!fdYZ"ej edej!fdYZ#de fdYZ$de%fdYZ&de%fdYZ'de fdYZ(defdYZ)ej ede)fdYZ*de%fdYZ+de fd YZ,d!e%fd"YZ-ej.d#krd$d%gZ/d&d'd(d)gZ0n gZ/gZ0d*Z1e1Z2[1ed+Z3ed,Z4d-Z5d.Z6d/e%fd0YZ7dS(1s 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 string_types(t_threadi(ttzname_in_python2t_tzinfo(t tzrangebasetenfold(t_validate_fromutc_inputs(t _TzSingletont_TzOffsetFactory(t _TzStrFactory(ttzwint tzwinlocalittzutccBsqeZdZdZdZedZdZedZ 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-xdEqop/python-dateutil/dateutil/tz/tz.pyt utcoffsetEscCstS(N(R (RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pytdstHscCsdS(NtUTC((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyttznameKscCstS(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-xdEqop/python-dateutil/dateutil/tz/tz.pyt is_ambiguousOscCs|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-xdEqop/python-dateutil/dateutil/tz/tz.pytfromutc_scCsDt|ttfstSt|tpCt|toC|jtkS(N(t isinstanceR ttzoffsettNotImplementedt_offsetR (Rtother((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt__eq__gscCs ||k S(N((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt__ne__pscCsd|jjS(Ns%s()(t __class__t__name__(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt__repr__ssN(Rt __module__t__doc__RRRRRRRRtNonet__hash__RR tobjectt __reduce__(((s9/tmp/pip-install-xdEqop/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). cCsL||_y|j}Wnttfk r2nXtjd||_dS(Ntseconds(t_namet total_secondst TypeErrortAttributeErrortdatetimet timedeltaR(Rtnametoffset((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt__init__s  cCs|jS(N(R(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCstS(N(R (RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCs|jS(N(R((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCs ||jS(N(R(RR((s9/tmp/pip-install-xdEqop/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-xdEqop/python-dateutil/dateutil/tz/tz.pyRs cCs#t|tstS|j|jkS(N(RRRR(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCs ||k S(N((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCs/d|jjt|jt|jjfS(Ns %s(%s, %s)(RRtreprR(tintRR)(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR s  N(RR!R"R0RRRRRRRRR#R$RR R%R&(((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRys       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'(tsuperR3R0R,R-ttimettimezonet _std_offsettdaylighttaltzonet _dst_offsett _dst_savedtboolt_hasdstttupleRt_tznames(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0s  cCs:|dkr|jrdS|j|r/|jS|jSdS(N(R#R=t_isdstR:R7(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRs cCs>|dkr|jrdS|j|r6|j|jStSdS(N(R#R=R@R:R7R (RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRs cCs|j|j|S(N(R?R@(RR((s9/tmp/pip-install-xdEqop/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-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCs#t|}tj|tjjS(N(t_datetime_to_timestampR5t localtimeR6ttm_isdst(RRt timestamp((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRAs cCsb|js tS|j|}t|dd}|j|r^|dk rW|j| StSn|S(Ntfold(R=RRAtgetattrR#Rt_foldtTrue(RRt fold_naivetdstvalRG((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR@s  cCst|tr1|j|jko0|j|jkSt|trp|j oo|jdddhkoo|jtkSt|tr|j o|jd|j ko|j|j kSt SdS(NiRtGMT( RR3R7R:R R=R?R RR(RR(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR"s   cCs ||k S(N((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR3scCsd|jjS(Ns%s()(RR(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR 6sN(RR!R"R0RRRRRRARJR@RR#R$RR R%R&(((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR3s    (   t_ttinfocBs_eZdddddddgZdZdZd Zd Zd Zd Z d Z RS(R/tdeltatisdsttabbrtisstdtisgmtt dstoffsetcCs(x!|jD]}t||dq WdS(N(t __slots__tsetattrR#(Rtattr((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0@scCsrg}xL|jD]A}t||}|dk r|jd|t|fqqWd|jjdj|fS(Ns%s=%ss%s(%s)s, (RURHR#tappendR1RRtjoin(RtlRWtvalue((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR Ds  $cCst|tstS|j|jko|j|jko|j|jko|j|jko|j|jko|j|jko|j |j kS(N( RRNRR/RORPRQRRRSRT(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRLscCs ||k S(N((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRZscCs4i}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(NtrbR.(R4RkR0RRRt _filenametopenRJR#thasattrR.R1t_ContextWrappert _read_tzfilet _set_tzdata(Rtfileobjtfilenametfile_opened_heret file_streamttzobj((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0s"      cCs5x.tjD]#}t|d|t||q WdS(s= Set the time zone data of this object from a _tzfile object t_N(R_RhRVRH(RRwRW((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRrscCsmt}|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]} | | \}}}d |dd }t}||_tjd|_tjd||_||_| || jd|!|_|| ko[| | dk|_|| koz| | dk|_|jj |qWg|jD]}|j|^q|_d|_d|_d|_|jr|js|jd|_|_qxt |dddD]h} |j| }|j rK|j rK||_n|j rj|jrj||_n|jr|jrPqqW|jr|j r|j|_nx:|jD]}|js||_PqqW|jd|_nd}g|_xt |jD]z\} }|js)|j}|}n8|dk rU|j||_||j| 6lis>%dls>%dBs>lbbiis>%dbi<iiR'tii(%R_treadtdecodet ValueErrortstructtunpacktlistRaRbtrangeRXtseektostSEEK_CURRcRNR/R,R-RTRORPtfindRQRRRSR#RdReRfRgR`t enumeratetreversedtlenRR>(RRstoutt ttisgmtcntt ttisstdcnttleapcntttimecntttypecnttcharcnttttinfotiRQRRRStgmtoffRPtabbrindtttitidxt laststdoffsetR/((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRqs  -    &         &                 "   cCsK|js dSt|}|r(|jn|j}tj||}|dS(Ni(t _trans_listR#RCt_trans_list_utctbisectt bisect_right(RRtin_utcRFR`R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt_find_last_transitions   cCsJ|dks%|dt|jkr,|jS|dkr?|jS|j|S(Nii(R#RRt _ttinfo_stdt_ttinfo_beforet _trans_idx(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt _get_ttinfos % cCs|j|}|j|S(N(t_resolve_ambiguous_timeR(RRR((s9/tmp/pip-install-xdEqop/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'RRG( RR,R*ttzinfoR}RRJRR-R/RRR2(RRRRtdt_outRG((s9/tmp/pip-install-xdEqop/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#RRCRRR/R(RRRRFRtodttt((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRs   cCsa|j|}|j|}|dks6|dkr:|St| oS|j||}||S(Ni(RRIR#R2R(RRRRIt idx_offset((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRs cCs-|dkrdS|jstS|j|jS(N(R#RR RRO(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR%s   cCs@|dkrdS|jstS|j|}|js9tS|jS(N(R#t _ttinfo_dstR RRPRT(RRR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR.s   cCs*|j s|dkrdS|j|jS(N(RR#RRQ(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR>scCsGt|tstS|j|jkoF|j|jkoF|j|jkS(N(RRkRRRt _ttinfo_list(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRDs cCs ||k S(N((RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRMscCsd|jjt|jfS(Ns%s(%s)(RRR1Rm(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR PscCs |jdS(N(t __reduce_ex__R#(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR&SscCs|jd|jf|jfS(N(RR#Rmt__dict__(Rtprotocol((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRVsN(RR!R"R#R0RrRqRRRRRRRRRRRRR$RR R&R(((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRkvs&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-R7R R:tSUt _start_deltat _end_deltat_dst_base_offset_R<thasdst(Rtstdabbrt stdoffsettdstabbrRTtstarttend((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0s:        ,  + 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-xdEqop/python-dateutil/dateutil/tz/tz.pyt transitionss    cCs}t|tstS|j|jko||j|jko||j|jko||j|jko||j|jko||j|jkS(N( RRRRRR7R:RR(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRscCs|jS(N(R(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt_dst_base_offsetsN( RR!R"R#R0RRtpropertyR(((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRZsJ-  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 formatRMRRRtisendi(sGMTsUTC(tdateutil.parserRtparsert_st_parsetzR#tany_unused_tokensR}RRRR0RRTRRRt_deltaRRR<R(Rtst posix_offsettres((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0's"      icCsddlm}i}|jdk r|j|d<|jdk r|j|j|j|d<|jdkryd|d|jdk r|j|d (R1R(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR s( RR!R0RRRRRRR R%R&(((s9/tmp/pip-install-xdEqop/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(RtrR.( RRRRRRnRHR1Rpt_vtzt _parse_rfcR{(RRstfobj((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0s    cCst|jjS(s? Retrieves the available time zones as a list. (RRtkeys(R((s9/tmp/pip-install-xdEqop/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#RRR}tnexttiterRi(RR((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRis 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(tstripR}RR2(RRtsignal((s9/tmp/pip-install-xdEqop/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 cSsi|_tj|_dS(N(t_GettzFunc__instancesRRR(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0s csu|jf|jj|d}|dkrk|jd|}|dkpUt|sk||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#RBR,R-R(Rt curr_offsett old_offset((s9/tmp/pip-install-xdEqop/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-xdEqop/python-dateutil/dateutil/tz/tz.pyRCsRpcBs)eZdZdZdZdZRS(s^ Class for wrapping contexts so that they are passed through in a with statement. cCs ||_dS(N(tcontext(RRN((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyR0scCs|jS(N(RN(R((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt __enter__scOsdS(N((targsRj((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt__exit__s(RR!R"R0RORQ(((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyRps  (8R"R,R~R5tsysRRtsixRt six.movesRt_commonRRRRRt _factoriesRRR twinR R t ImportErrorR#R-R tutcfromtimestampRMt toordinalt EPOCHORDINALt add_metaclassRR RR3R%RNR_RkRRRRRtplatformR1R4R?tgettzRBRIRLRCRp(((s9/tmp/pip-install-xdEqop/python-dateutil/dateutil/tz/tz.pyt sh         TC- w V    " . .