Server IP : 149.255.58.128 / Your IP : 216.73.216.23
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Upload Files :
Command :
Current File : /usr/lib/python3.9/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 a negilible difference
to be considered equal.
"""
delta = abs(delta)
difference = dt1 - dt2
return -delta <= difference <= delta
Name |
Size |
Last Modified |
Owner / Group |
Permissions |
Options |
.. | -- | March 19 2025 22:42:16 | 0 / root | 0755 | |
__pycache__ | -- | February 04 2024 10:27:16 | 0 / root | 0755 | |
parser | -- | February 04 2024 10:27:16 | 0 / root | 0755 | |
tz | -- | February 04 2024 10:27:16 | 0 / root | 0755 | |
zoneinfo | -- | February 04 2024 10:27:16 | 0 / root | 0755 | |
| | | | | |
__init__.py | 0.217 KB | October 25 2018 16:30:05 | 0 / root | 0644 | |
_common.py | 0.91 KB | June 22 2018 13:08:09 | 0 / root | 0644 | |
_version.py | 0.139 KB | September 27 2023 01:27:24 | 0 / root | 0644 | |
easter.py | 2.621 KB | October 25 2018 16:30:05 | 0 / root | 0644 | |
relativedelta.py | 24.32 KB | November 03 2019 00:14:10 | 0 / root | 0644 | |
rrule.py | 64.955 KB | November 03 2019 00:14:10 | 0 / root | 0644 | |
tzwin.py | 0.058 KB | December 05 2017 14:13:52 | 0 / root | 0644 | |
utils.py | 1.913 KB | November 03 2019 00:14:10 | 0 / root | 0644 | |