From 92b2d01a8a8d273f17d60d9f9abc607a0c308b81 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Sun, 11 Nov 2018 18:22:09 -0800 Subject: [PATCH] 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. --- lib/ansible/modules/network/f5/bigip_device_facts.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/f5/bigip_device_facts.py b/lib/ansible/modules/network/f5/bigip_device_facts.py index 1f0fab5419..3c1b390f8b 100644 --- a/lib/ansible/modules/network/f5/bigip_device_facts.py +++ b/lib/ansible/modules/network/f5/bigip_device_facts.py @@ -11302,7 +11302,15 @@ class SoftwareImagesParameters(BaseParameters): """ if self._values['build_date'] is 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 @property