1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-02 18:36:19 +00:00

remove conditional code for old snakes (#11048)

* remove conditional code for old snakes

* remove conditional code for old snakes

* reformat

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-11-09 05:21:46 +13:00 committed by GitHub
parent 3478863ef0
commit ebf45260ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 26 additions and 105 deletions

View file

@ -6,25 +6,17 @@
from __future__ import annotations
import datetime as _datetime
import sys
_USE_TIMEZONE = sys.version_info >= (3, 6)
def ensure_timezone_info(value):
if not _USE_TIMEZONE or value.tzinfo is not None:
if value.tzinfo is not None:
return value
return value.astimezone(_datetime.timezone.utc)
def fromtimestamp(value):
if _USE_TIMEZONE:
return _datetime.fromtimestamp(value, tz=_datetime.timezone.utc)
return _datetime.utcfromtimestamp(value)
return _datetime.fromtimestamp(value, tz=_datetime.timezone.utc)
def now():
if _USE_TIMEZONE:
return _datetime.datetime.now(tz=_datetime.timezone.utc)
return _datetime.datetime.utcnow()
return _datetime.datetime.now(tz=_datetime.timezone.utc)