mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Workaround for problems parsing the timezone (#48549)
Device facts gets a time with a timezone back from the builddate. Unfortunately, python cannot correctly parse timezones by default. This hacks around the problem.
This commit is contained in:
parent
ab8125f2a6
commit
92b2d01a8a
1 changed files with 9 additions and 1 deletions
|
@ -11302,7 +11302,15 @@ class SoftwareImagesParameters(BaseParameters):
|
||||||
"""
|
"""
|
||||||
if self._values['build_date'] is None:
|
if self._values['build_date'] is None:
|
||||||
return None
|
return None
|
||||||
result = datetime.datetime.strptime(self._values['build_date'], '%a %b %d %H %M %S PDT %Y').isoformat()
|
|
||||||
|
d = self._values['build_date'].split(' ')
|
||||||
|
|
||||||
|
# This removes the timezone portion from the string. This is done
|
||||||
|
# because Python has awfule tz parsing and strptime doesnt work with
|
||||||
|
# all timezones in %Z; it only uses the timezones found in time.tzname
|
||||||
|
d.pop(6)
|
||||||
|
|
||||||
|
result = datetime.datetime.strptime(' '.join(d), '%a %b %d %H %M %S %Y').isoformat()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue