a
    ¢Àóf­  ã                   @   s>   d Z ddlmZ ddlmZmZ ddd„Zdd„ Zd	d
„ ZdS )zs
This module offers general convenience and utility functions for dealing with
datetimes.

.. versionadded:: 2.7.0
é    )Úunicode_literals)ÚdatetimeÚtimeNc                 C   s"   t  | ¡}t  | ¡ td| d�¡S )a  
    Returns a :py:class:`datetime` representing the current day at midnight

    :param tzinfo:
        The time zone to attach (also used to determine the current day).

    :return:
        A :py:class:`datetime.datetime` object representing the current day
        at midnight.
    r   ©Útzinfo)r   ÚnowÚcombineÚdater   )r   Údt© r   úK/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/dateutil/utils.pyÚtoday   s    
r   c                 C   s   | j dur| S | j|d�S dS )a¤  
    Sets the ``tzinfo`` parameter on naive datetimes only

    This is useful for example when you are provided a datetime that may have
    either an implicit or explicit time zone, such as when parsing a time zone
    string.

    .. doctest::

        >>> from dateutil.tz import tzoffset
        >>> from dateutil.parser import parse
        >>> from dateutil.utils import default_tzinfo
        >>> dflt_tz = tzoffset("EST", -18000)
        >>> print(default_tzinfo(parse('2014-01-01 12:30 UTC'), dflt_tz))
        2014-01-01 12:30:00+00:00
        >>> print(default_tzinfo(parse('2014-01-01 12:30'), dflt_tz))
        2014-01-01 12:30:00-05:00

    :param dt:
        The datetime on which to replace the time zone

    :param tzinfo:
        The :py:class:`datetime.tzinfo` subclass instance to assign to
        ``dt`` if (and only if) it is naive.

    :return:
        Returns an aware :py:class:`datetime.datetime`.
    Nr   )r   Úreplace)r
   r   r   r   r   Údefault_tzinfo   s    
r   c                 C   s*   t |ƒ}| | }| |  ko$|kS   S )zn
    Useful for comparing two datetimes that may have a negligible difference
    to be considered equal.
    )Úabs)Zdt1Zdt2ÚdeltaÚ
differencer   r   r   Úwithin_delta@   s    r   )N)Ú__doc__Ú
__future__r   r   r   r   r   r   r   r   r   r   Ú<module>   s
   
#