$12 GRAYBYTE WORDPRESS FILE MANAGER $66

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/imunify360/venv/lib/python3.11/site-packages/dateutil/

HOME
Current File : /opt/imunify360/venv/lib/python3.11/site-packages/dateutil//utils.py
# -*- coding: utf-8 -*-
"""
This module offers general convenience and utility functions for dealing with
datetimes.

.. versionadded:: 2.7.0
"""
from __future__ import unicode_literals

from datetime import datetime, time


def today(tzinfo=None):
    """
    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.
    """

    dt = datetime.now(tzinfo)
    return datetime.combine(dt.date(), time(0, tzinfo=tzinfo))


def default_tzinfo(dt, tzinfo):
    """
    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`.
    """
    if dt.tzinfo is not None:
        return dt
    else:
        return dt.replace(tzinfo=tzinfo)


def within_delta(dt1, dt2, delta):
    """
    Useful for comparing two datetimes that may have a negligible difference
    to be considered equal.
    """
    delta = abs(delta)
    difference = dt1 - dt2
    return -delta <= difference <= delta

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.34 PM
root / root
0755
__pycache__
--
5 Aug 2025 4.31 AM
root / root
0755
parser
--
5 Aug 2025 4.30 AM
root / root
0755
tz
--
5 Aug 2025 4.30 AM
root / root
0755
zoneinfo
--
5 Aug 2025 4.30 AM
root / root
0755
__init__.py
0.217 KB
4 Jul 2025 8.31 PM
root / root
0644
_common.py
0.91 KB
4 Jul 2025 8.31 PM
root / root
0644
_version.py
0.139 KB
4 Jul 2025 8.31 PM
root / root
0644
easter.py
2.615 KB
4 Jul 2025 8.31 PM
root / root
0644
relativedelta.py
24.32 KB
4 Jul 2025 8.31 PM
root / root
0644
rrule.py
64.996 KB
4 Jul 2025 8.31 PM
root / root
0644
tzwin.py
0.058 KB
4 Jul 2025 8.31 PM
root / root
0644
utils.py
1.919 KB
4 Jul 2025 8.31 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF