mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-31 21:39:10 -07:00
[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:
parent
83738f21a3
commit
4832100d76
19 changed files with 142 additions and 64 deletions
|
@ -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"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue