§
    ¬eîi.  ã            
       óv  — d Z ddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ erddlmZ ej        j        Z	 ddlZn# e$ r dZY nw xY wdej        dej        d	ej        fd
„Z	 	 ddeej        z  ej        z  ej        z  dedz  dej        dz  d	efd„Z	 	 ddeej        z  ej        z  ej        z  dz  dedz  dej        dz  d	edz  fd„Z	 ddedz  dej        dz  d	ej        dz  fd„Zddd	ej        dz  fd„Zdej        d	efd„Zded	ej        fd„Z dej        dz  ded	eej        z  dz  fd„Z!dS )aÑ  This module contains helper functions related to datetime and timestamp conversations.

.. versionchanged:: 20.0
   Previously, the contents of this module were available through the (no longer existing)
   module ``telegram._utils.helpers``.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
é    N)ÚTYPE_CHECKING)Úwarn)ÚPTBDeprecationWarning)ÚBotÚdatetimeÚtzinfoÚreturnc                 óˆ  — |t           u r|                      t           ¬¦  «        S t          j        t          ¦  «        5  t          |t          j        ¦  «        r!|                     | ¦  «        cddd¦  «         S 	 ddd¦  «         n# 1 swxY w Y   | j	        €|                      |¬¦  «        S |  
                    |¦  «        S )z<Localize the datetime, both for pytz and zoneinfo timezones.©r   N)ÚUTCÚreplaceÚ
contextlibÚsuppressÚAttributeErrorÚ
isinstanceÚpytzÚ
BaseTzInfoÚlocalizer   Ú
astimezone)r   r   s     ú\/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/_utils/datetime.pyr   r   3   s  € à•€}€}Ø×Ò¥sÐÑ+Ô+Ð+å	Ô	�^Ñ	,Ô	,ð -ð -å�f�dœoÑ.Ô.ð 	-Ø—?’? 8Ñ,Ô,ð-ð -ð -ð -ñ -ô -ð -ð -ð	-ð-ð -ð -ñ -ô -ð -ð -ð -ð -ð -ð -øøøð -ð -ð -ð -ð
 „ÐØ×Ò vÐÑ.Ô.Ð.Ø×Ò˜vÑ&Ô&Ð&s   ¾/BÂBÂBÚtime_objectÚreference_timestampc                 óÂ  — |€t          j         ¦   «         }n)t          | t          j        ¦  «        rt	          d¦  «        ‚t          | t          j        ¦  «        r||                      ¦   «         z   S t          | t          t          z  ¦  «        r|| z   S |€t          }t          | t          j         ¦  «        rÆt          j         
                    || j        p|¬¦  «        }|                     ¦   «         }|                     ¦   «         }t          j                             || ¦  «        }|j        €t          ||¦  «        }||                     ¦   «         k    r|t          j        d¬¦  «        z  }t!          |¦  «        S t          | t          j        ¦  «        r&| j        €t          | |¦  «        } t!          | ¦  «        S t#          dt%          | ¦  «        j        › d�¦  «        ‚)aà  
    Converts a given time object to a float POSIX timestamp.
    Used to convert different time specifications to a common format. The time object
    can be relative (i.e. indicate a time increment, or a time of day) or absolute.
    Objects from the :class:`datetime` module that are timezone-naive will be assumed
    to be in UTC, if ``bot`` is not passed or ``bot.defaults`` is :obj:`None`.

    Args:
        time_object (:obj:`float` | :obj:`datetime.timedelta` |             :obj:`datetime.datetime` | :obj:`datetime.time`):
            Time value to convert. The semantics of this parameter will depend on its type:

            * :obj:`float` will be interpreted as "seconds from :paramref:`reference_t`"
            * :obj:`datetime.timedelta` will be interpreted as
              "time increment from :paramref:`reference_timestamp`"
            * :obj:`datetime.datetime` will be interpreted as an absolute date/time value
            * :obj:`datetime.time` will be interpreted as a specific time of day

        reference_timestamp (:obj:`float`, optional): POSIX timestamp that indicates the absolute
            time from which relative calculations are to be performed (e.g. when
            :paramref:`time_object` is given as an :obj:`int`, indicating "seconds from
            :paramref:`reference_time`"). Defaults to now (the time at which this function is
            called).

            If :paramref:`time_object` is given as an absolute representation of date & time (i.e.
            a :obj:`datetime.datetime` object), :paramref:`reference_timestamp` is not relevant
            and so its value should be :obj:`None`. If this is not the case, a :exc:`ValueError`
            will be raised.
        tzinfo (:class:`datetime.tzinfo`, optional): If :paramref:`time_object` is a naive object
            from the :mod:`datetime` module, it will be interpreted as this timezone. Defaults to
            :attr:`datetime.timezone.utc` otherwise.

            Note:
                Only to be used by ``telegram.ext``.

    Returns:
        :obj:`float` | :obj:`None`:
            The return value depends on the type of argument :paramref:`time_object`.
            If :paramref:`time_object` is given as a time increment (i.e. as a :obj:`int`,
            :obj:`float` or :obj:`datetime.timedelta`), then the return value will be
            :paramref:`reference_timestamp` + :paramref:`time_object`.

            Else if it is given as an absolute date/time value (i.e. a :obj:`datetime.datetime`
            object), the equivalent value as a POSIX timestamp will be returned.

            Finally, if it is a time of the day without date (i.e. a :obj:`datetime.time`
            object), the return value is the nearest future occurrence of that time of day.

    Raises:
        TypeError: If :paramref:`time_object` s type is not one of those described above.
        ValueError: If :paramref:`time_object` is a :obj:`datetime.datetime` and
            :paramref:`reference_timestamp` is not :obj:`None`.
    NzAt is an (absolute) datetime while reference_timestamp is not None©Útzé   )ÚdayszUnable to convert z object to timestamp)Útimer   Údtmr   Ú
ValueErrorÚ	timedeltaÚtotal_secondsÚintÚfloatr   Úfromtimestampr   ÚdateÚtimetzÚcombiner   Ú_datetime_to_float_timestampÚ	TypeErrorÚtypeÚ__name__)r   r   r   Úreference_dtÚreference_dateÚreference_timeÚaware_datetimes          r   Úto_float_timestampr1   B   sÆ  € ðt Ð"Ý"œi™kœkÐÐÝ	�K¥¤Ñ	.Ô	.ð ^ÝÐ\Ñ]Ô]Ð]å�+�sœ}Ñ-Ô-ð AØ" [×%>Ò%>Ñ%@Ô%@Ñ@Ð@Ý�+�s¥U™{Ñ+Ô+ð 1Ø" [Ñ0Ð0à€~õ ˆå�+�sœxÑ(Ô(ð <Ý”|×1Ò1Ø KÔ$6Ð$@¸&ð 2ñ 
ô 
ˆð &×*Ò*Ñ,Ô,ˆØ%×,Ò,Ñ.Ô.ˆåœ×-Ò-¨n¸kÑJÔJˆØÔ Ð(õ & n°fÑ=Ô=ˆNð ˜N×1Ò1Ñ3Ô3Ò3Ð3Ø�cœm°Ð3Ñ3Ô3Ñ3ˆNÝ+¨NÑ;Ô;Ð;Ý�+�sœ|Ñ,Ô,ð 9ØÔÐ%Ý" ;°Ñ7Ô7ˆKÝ+¨KÑ8Ô8Ð8å
ÐY­¨kÑ):Ô):Ô)CÐYÐYÐYÑ
ZÔ
ZÐZó    Údt_objc                 óF   — | �t          t          | ||¦  «        ¦  «        ndS )zÓ
    Wrapper over :func:`to_float_timestamp` which returns an integer (the float value truncated
    down to the nearest integer).

    See the documentation for :func:`to_float_timestamp` for more details.
    N)r#   r1   )r3   r   r   s      r   Úto_timestampr5   ¨   s0   € ð Ðõ 	Õ˜vÐ':¸FÑCÔCÑDÔDÐDàðr2   Úunixtimec                 ó^   — | €dS t           j                             | |€t          n|¬¦  «        S )ai  
    Converts an (integer) unix timestamp to a timezone aware datetime object.
    :obj:`None` s are left alone (i.e. ``from_timestamp(None)`` is :obj:`None`).

    Args:
        unixtime (:obj:`int`): Integer POSIX timestamp.
        tzinfo (:obj:`datetime.tzinfo`, optional): The timezone to which the timestamp is to be
            converted to. Defaults to :obj:`None`, in which case the returned datetime object will
            be timezone aware and in UTC.

    Returns:
        Timezone aware equivalent :obj:`datetime.datetime` value if :paramref:`unixtime` is not
        :obj:`None`; else :obj:`None`.
    Nr   )r   r   r%   r   )r6   r   s     r   Úfrom_timestampr8   º   s2   € ð$ ÐØˆtåŒ<×%Ò% h¸&¸.µ3°3ÈfÐ%ÑUÔUÐUr2   Úbotz
Bot | Nonec                 óT   — | €dS t          | d¦  «        r| j        r| j        j        S dS )z‡
    Extracts the timezone info from the default values of the bot.
    If the bot has no default values, :obj:`None` is returned.
    NÚdefaults)Úhasattrr;   r   )r9   s    r   Úextract_tzinfo_from_defaultsr=   Ò   s9   € ð €{Øˆtåˆs�JÑÔð # C¤Lð #ØŒ|Ô"Ð"Øˆ4r2   c                 ó‚   — | j         €%|                      t          j        j        ¬¦  «        } |                      ¦   «         S )z 
    Converts a datetime object to a float timestamp (with sub-second precision).
    If the datetime object is timezone-naive, it is assumed to be in UTC.
    Nr   )r   r   r   ÚtimezoneÚutcÚ	timestamp)r3   s    r   r)   r)   á   s6   € ð
 „}ÐØ—’¥s¤|Ô'7�Ñ8Ô8ˆØ×ÒÑÔÐr2   r   c                 óŒ   — 	 t          j        | ¦  «        S # t           j        $ r}t          j        d| › d�¦  «        |‚d}~ww xY w)z|Wrapper around the `ZoneInfo` constructor with slightly more helpful error message
    in case tzdata is not installed.
    zNo time zone found with key z©. Make sure to use a valid time zone name and correctly install the tzdata (https://pypi.org/project/tzdata/) package if your system does not provide the time zone data.N)ÚzoneinfoÚZoneInfoÚZoneInfoNotFoundError)r   Úerrs     r   Úget_zone_inforG   ë   sj   € ðÝÔ  Ñ$Ô$Ð$øÝÔ)ð ð ð ÝÔ,ð?¨2ð ?ð ?ð ?ñ
ô 
ð
 ð	øøøøðøøøs   ‚ –A¥>¾AÚvalueÚ	attributec                 ó<  — | €dS t          j        dd¦  «                             ¦   «                              ¦   «         dv r| S t	          t          dd|› d�¦  «        d¬	¦  «         |                      ¦   «         x}                     ¦   «         rt          |¦  «        n|S )
aP  
    Convert a `datetime.timedelta` to seconds or return it as-is, based on environment config.

    This utility is part of the migration process from integer-based time representations
    to using `datetime.timedelta`. The behavior is controlled by the `PTB_TIMEDELTA`
    environment variable.

    Note:
        When `PTB_TIMEDELTA` is not enabled, the function will issue a deprecation warning.

    Args:
        value (:obj:`datetime.timedelta`): The timedelta value to process.
        attribute (:obj:`str`): The name of the attribute at the caller scope, used for
            warning messages.

    Returns:
        - :obj:`None` if :paramref:`value` is None.
        - :obj:`datetime.timedelta` if `PTB_TIMEDELTA=true` or ``PTB_TIMEDELTA=1``.
        - :obj:`int` if the total seconds is a whole number.
        - float: otherwise.
    NÚPTB_TIMEDELTAÚfalse)ÚtrueÚ1zv22.2z%In a future major version attribute `z�` will be of type `datetime.timedelta`. You can opt-in early by setting `PTB_TIMEDELTA=true` or ``PTB_TIMEDELTA=1`` as an environment variable.é   )Ú
stacklevel)	ÚosÚgetenvÚlowerÚstripr   r   r"   Ú
is_integerr#   )rH   rI   Úsecondss      r   Úget_timedelta_valuerW   ú   sÁ   € ð, €}ØˆtÝ	„y� 'Ñ*Ô*×0Ò0Ñ2Ô2×8Ò8Ñ:Ô:¸mÐKÐKØˆÝÝØðB°Ið Bð Bð Bñ	
ô 	
ð ðñ ô ð ð ×*Ò*Ñ,Ô,Ð,ˆG×8Ò8Ñ:Ô:ð	�ˆG‰Œˆàðr2   )NN)N)"Ú__doc__r   r   r   rQ   r   rC   Útypingr   Útelegram._utils.warningsr   Útelegram.warningsr   Útelegramr   r?   r@   r   r   ÚImportErrorr   r   r$   r!   r1   r#   r5   r8   r=   r)   ÚstrrD   rG   rW   © r2   r   ú<module>r`      sò  ðð&
ð 
ð Ð Ð Ð Ø Ð Ð Ð Ø 	€	€	€	Ø €€€Ø €€€Ø  Ð  Ð  Ð  Ð  Ð  à )Ð )Ð )Ð )Ð )Ð )Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3àð ØÐÐÐÐÐà	„lÔ€ðØ€K€K€K€KøØð ð ð Ø€D€D€Dðøøøð'�s”|ð '¨S¬Zð '¸C¼Lð 'ð 'ð 'ð 'ð" )-Ø $ðc[ð c[Ø˜œÑ&¨¬Ñ5¸¼Ñ@ðc[à ™ðc[ð ŒJ˜Ñðc[ð ð	c[ð c[ð c[ð c[ðP )-Ø $ðð Ø�C”MÑ! C¤LÑ0°3´8Ñ;¸dÑBðà ™ðð ŒJ˜Ñðð 	ˆ4�Zð	ð ð ð ð( !%ðVð VØ�D‰jðVàŒJ˜ÑðVð 	„\�DÑðVð Vð Vð Vð0 lð °s´zÀDÑ7Hð ð ð ð ð¨¬ð ¸%ð ð ð ð ð�cð ˜hÔ/ð ð ð ð ð'˜sœ}¨tÑ3ð 'Àð 'ÈÈcÌmÑH[Ð^bÑHbð 'ð 'ð 'ð 'ð 'ð 's   ¾A ÁAÁA