1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00
community.general/plugins/module_utils/datetime.py
patchback[bot] caebf65948
[PR #11048/ebf45260 backport][stable-12] remove conditional code for old snakes (#11050)
remove conditional code for old snakes (#11048)

* remove conditional code for old snakes

* remove conditional code for old snakes

* reformat

* add changelog frag

(cherry picked from commit ebf45260ce)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
2025-11-08 20:55:09 +01:00

22 lines
579 B
Python

#
# Copyright (c) 2023 Felix Fontein <felix@fontein.de>
# Simplified BSD License (see LICENSES/BSD-2-Clause.txt or https://opensource.org/licenses/BSD-2-Clause)
# SPDX-License-Identifier: BSD-2-Clause
from __future__ import annotations
import datetime as _datetime
def ensure_timezone_info(value):
if value.tzinfo is not None:
return value
return value.astimezone(_datetime.timezone.utc)
def fromtimestamp(value):
return _datetime.fromtimestamp(value, tz=_datetime.timezone.utc)
def now():
return _datetime.datetime.now(tz=_datetime.timezone.utc)