[PR #8222/524d5883 backport][stable-8] Avoid deprecated utcnow() (#8243)

Avoid deprecated utcnow() (#8222)

Avoid deprecated utcnow().

(cherry picked from commit 524d5883b8)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2024-04-20 10:21:02 +02:00 committed by GitHub
parent 83738f21a3
commit 4832100d76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 142 additions and 64 deletions

View file

@ -188,6 +188,10 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
from ansible.module_utils.urls import open_url
from ansible_collections.community.general.plugins.module_utils.datetime import (
now,
)
def get_api_auth_headers(api_id, api_key, url, statuspage):
@ -270,11 +274,11 @@ def get_date_time(start_date, start_time, minutes):
except (NameError, ValueError):
return 1, None, "Couldn't work out a valid date"
else:
now = datetime.datetime.utcnow()
delta = now + datetime.timedelta(minutes=minutes)
now_t = now()
delta = now_t + datetime.timedelta(minutes=minutes)
# start_date
returned_date.append(now.strftime("%m/%d/%Y"))
returned_date.append(now.strftime("%H:%M"))
returned_date.append(now_t.strftime("%m/%d/%Y"))
returned_date.append(now_t.strftime("%H:%M"))
# end_date
returned_date.append(delta.strftime("%m/%d/%Y"))
returned_date.append(delta.strftime("%H:%M"))