| Server IP : 173.249.148.11 / Your IP : 216.73.216.6 Web Server : Apache/2.4.68 (AlmaLinux) System : Linux developmentwebsite.ca 4.18.0-553.168.1.el8_10.x86_64 #1 SMP Thu Sep 24 18:05:46 UTC 2026 x86_64 User : devinter ( 1006) PHP Version : 8.3.35 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /snap/certbot/current/lib/python3.12/site-packages/pyrfc3339/ |
Upload File : |
from datetime import datetime
def datetime_utcoffset(dt: datetime) -> float:
"""
Return the UTC offset for an aware :class:`datetime.datetime` in seconds.
>>> from datetime import datetime
>>> from zoneinfo import ZoneInfo
>>> z = ZoneInfo('US/Eastern')
>>> dt = datetime(2024, 11, 5, 19, 7, 6, tzinfo=z)
>>> datetime_utcoffset(dt)
-18000.0
>>> dt = datetime(2024, 11, 5, 19, 7, 6)
>>> datetime_utcoffset(dt)
Traceback (most recent call last):
...
AssertionError
:param datetime.datetime dt: a :class:`~datetime.datetime` instance; must be aware (that is, have a timezone attached)
:return: the UTC offset of the supplied :class:`~datetime.datetime` in seconds
:rtype: float
"""
assert dt.tzinfo is not None
tz = dt.tzinfo
offset = tz.utcoffset(dt)
assert offset is not None
return offset.total_seconds()