r4i2ddlmZddlmZddlmZmZmZedZddgZdZ e edrddZ nGd d eZ dd Z d Z Gd deZGddeZy))PY2wraps)datetime timedeltatzinfotzname_in_python2enfoldc>trtfd}|SS)zChange unicode output into bytestrings in Python 2 tzname() API changed in Python 3. It used to return bytes, but was changed to unicode strings c<|i|}||j}|SN)encode)argskwargsnamenamefuncs _/mnt/ssd/data/python-lab/DaemonControl/venv/lib/python3.12/site-packages/dateutil/tz/_common.pyadjust_encodingz*tzname_in_python2..adjust_encodings(T,V,D{{}K)rr)rrs` rr r s+  x   rfoldc&|j|S) Provides a unified interface for assigning the ``fold`` attribute to datetimes both before and after the implementation of PEP-495. :param fold: The value for the ``fold`` attribute in the returned datetime. This should be either 0 or 1. :return: Returns an object for which ``getattr(dt, 'fold', 0)`` returns ``fold`` for all versions of Python. In versions prior to Python 3.6, this is a ``_DatetimeWithFold`` object, which is a subclass of :py:class:`datetime.datetime` with the ``fold`` attribute added, if ``fold`` is 1. .. versionadded:: 2.6.0 rreplace)dtrs rr r %s$zztz$$rc*eZdZdZdZdZedZy)_DatetimeWithFoldz This is a class designed to provide a PEP 495-compliant interface for Python versions before 3.6. It is used only for dates in a fold, so the ``fold`` attribute is fixed at ``1``. .. versionadded:: 2.6.0 cd}t||D](\}}||vrtdj||||<*|D]}||vst||||<|j ddr |j nt }|di|S)a Return a datetime with the same attributes, except for those attributes given new values by whichever keyword arguments are specified. Note that tzinfo=None can be specified to create a naive datetime from an aware datetime with no conversion of date and time data. This is reimplemented in ``_DatetimeWithFold`` because pypy3 will return a ``datetime.datetime`` even if ``fold`` is unchanged. )yearmonthdayhourminutesecond microsecondrzDuplicate argument: {}rr)zip TypeErrorformatgetattrget __class__r)selfrrargnamesargargnamedt_classs rrz_DatetimeWithFold.replaceDsH !$D( 3 & Wf$#$<$C$CG$LMM"%w  & $ =&(&-dG&t~~HH%f% %rcy)Nr(rr/s rrz_DatetimeWithFold.foldbsrN)__name__ __module__ __qualname____doc__ __slots__rpropertyrrrrrr:s'   &<    rrct|dd|k(r|S|jdd}||j|jfz }|rt |St |S)rrrN)r, timetupler'rrr)rrrs rr r fs[$ 2vq !T )I||~bq! ++ $d+ +T? "rc.tfd}|S)z The CPython version of ``fromutc`` checks that the input is a ``datetime`` object and that ``self`` is attached as its ``tzinfo``. c~t|ts td|j|ur t d||S)N&fromutc() requires a datetime argumentdt.tzinfo is not self) isinstancerr*r ValueError)r/rfs rfromutcz)_validate_fromutc_inputs..fromutcs="h'DE E 99D 45 5r{rr)rErFs` r_validate_fromutc_inputsrGs"  1X Nrc8eZdZdZdZdZdZdZedZ y)_tzinfoz= Base class for all ``dateutil`` ``tzinfo`` objects. c|j|}t|d}t|d}|j|jk(}|jd|jdk(}|xr| S)6 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 rrrr(N)rr utcoffset)r/rwall_0wall_1 same_offsetsame_dts r is_ambiguousz_tzinfo.is_ambiguoussuZZtZ $##&&(F,<,<,>> ...-t1LL*{?*rc|j|r4||z }t||j|jz k(}|Sd}|S)a Determine the fold status of a "wall" datetime, given a representation of the same datetime as a (naive) UTC datetime. This is calculated based on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all datetimes, and that this offset is the actual number of hours separating ``dt_utc`` and ``dt_wall``. :param dt_utc: Representation of the datetime as UTC :param dt_wall: Representation of the datetime as "wall time". This parameter must either have a `fold` attribute or have a fold-naive :class:`datetime.tzinfo` attached, otherwise the calculation may fail. r)rRintrMdst)r/dt_utcdt_wall delta_wall_folds r _fold_statusz_tzinfo._fold_statussR"   W % 6)J v'7'7'9FJJL'HIJE E rct|ddS)Nrr)r,r/rs rrYz _tzinfo._foldsr61%%rc|j}| td|j}| td||z }||z }t|dj}| td||zS) Given a timezone-aware datetime in a given timezone, calculates a timezone-aware datetime in a new timezone. Since this is the one time that we *know* we have an unambiguous datetime object, we take this opportunity to determine whether the datetime is ambiguous and in a "fold" state (e.g. if it's the first occurrence, chronologically, of the ambiguous datetime). :param dt: A timezone-aware :class:`datetime.datetime` object. z0fromutc() requires a non-None utcoffset() resultz*fromutc() requires a non-None dst() resultr(rz;fromutc(): dt.dst gave inconsistent results; cannot convert)rMrDrUr )r/rdtoffdtdstdeltas r_fromutcz_tzinfo._fromutcs  =&' '  =IJ J  e r"&&( =78 8Ezrcb|j|}|j||}t||S)r^r)rbrZr )r/rrWrYs rrFz_tzinfo.fromutcs5--#!!"g.gE**rN) r6r7r8r9rRrZrYrbrGrFrrrrIrIs0+22&#J++rrIceZdZdZdZdZdZedZdZ dZ dZ d Z e d Zd Zd Zd Zej&Zy ) tzrangebasea This is an abstract base class for time zones represented by an annual transition into and out of DST. Child classes should implement the following methods: * ``__init__(self, *args, **kwargs)`` * ``transitions(self, year)`` - this is expected to return a tuple of datetimes representing the DST on and off transitions in standard time. A fully initialized ``tzrangebase`` subclass should also provide the following attributes: * ``hasdst``: Boolean whether or not the zone uses DST. * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects representing the respective UTC offsets. * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short abbreviations in DST and STD, respectively. * ``_hasdst``: Whether or not the zone has DST. .. versionadded:: 2.6.0 ctd)Nz%tzrangebase is an abstract base class)NotImplementedErrorr5s r__init__ztzrangebase.__init__!s!"IJJrc^|j|}|y|r |jS|jSr )_isdst _dst_offset _std_offsetr/risdsts rrMztzrangebase.utcoffset$s2 B = ## ### #rcR|j|}|y|r |jStSr )rj_dst_base_offsetZEROrms rrUztzrangebase.dst.s+ B = (( (KrcT|j|r |jS|jSr )rj _dst_abbr _std_abbrr\s rtznameztzrangebase.tzname8s! ;;r?>> !>> !rct|ts td|j|ur t d|j |j }|||j|zS|\}}||jz}||jz}||f}|jd}|j||}|r||jz}n||jz}t| xr|j|} t|| S)z, Given a datetime in UTC, return local time rArBNrLr)rCrr*rrD transitionsr!rMrlr _naive_isdstrkrTrRr ) r/rrwdstondstoffutc_transitionsrVrnrWrYs rrFztzrangebase.fromutc?s"h'DE E 99D 45 5&&rww/  r** *$ v !!!$""" &/4(!!&/: 4+++G4+++GI<$"3"3G"<=gE**rc|jsy|j|j\}}|jd}||cxkxr||jzkScS)rKFNrL)hasdstrwr!rrp)r/rstartends rrRztzrangebase.is_ambiguous`sW{{%%bgg. s ZZtZ $r7C$"7"777878rc|jsy|y|j|j}|y|jd}|j ||}|s#|j |r|j | S|S)NFrL)r}rwr!rrxrRrY)r/rrwrns rrjztzrangebase._isdstvs{{{ Z&&rww/   ZZtZ $!!"k2**2.zz"~% %Lrc|\}}|jd}||kr||cxkxr|k}|Sc}|S||cxkxr|knc }|S)NrLr)r/rrwryrzrns rrxztzrangebase._naive_isdsts_# v ZZtZ $ 6>R(&(E )E ",u,,E rc4|j|jz Sr )rkrlr5s rrpztzrangebase._dst_base_offsets$"2"222rNc||k( Sr r)r/others r__ne__ztzrangebase.__ne__sEM""rc4d|jjzS)Nz%s(...))r.r6r5s r__repr__ztzrangebase.__repr__s4>>2222r)r6r7r8r9rhrMrUr rurFrRrjrxr;rp__hash__rrobject __reduce__rrrrere sr*K$"" +B9,* 33H#3""JrreN)r()sixr functoolsrrrrrq__all__r hasattrr rrGrIrerrrrsp00|  ), 8V%**H*X#<"s+fs+lX#'X#r