diff options
author | Monty Taylor <mordred@inaugust.com> | 2017-12-02 11:11:23 -0600 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2017-12-02 11:15:26 -0600 |
commit | f0c9b20e0fd512e4eaa3f041a02afd80b871fe75 (patch) | |
tree | 0e5089b97bfed47bc7af0476aa4b20c585b5d96a | |
parent | 789301a388ba7e190de21e54300b0bb8e0ed6d18 (diff) | |
download | python-keystoneclient-f0c9b20e0fd512e4eaa3f041a02afd80b871fe75.tar.gz |
Handle UTC+00:00 in datetime strings
In some cases, the following:
datetime.datetime.now(tz=iso8601.iso8601.UTC).tzinfo.tzname()
returns:
'UTC+00:00'
rather than:
'UTC'
resulting in strings that look like:
2013-03-04T12:00:01.000000UTC+00:00
That is just flatly invalid. The code here accounts for a tzname of
"UTC" and normalizes to to being a trailing Z as-per the ISO 8601 spec,
but it does not account for UTC+00:00. Add support for that so that we
don't produce invalid date strings.
Most of this can be avoided by replacing use of this function with the
isoformat method of datetime instead.
datetime.datetime.now(tz=iso8601.iso8601.UTC).isoformat()
Produces
2013-03-04T12:00:01.000000+00:00
Which while different from
2013-03-04T12:00:01.000000Z
is still a valid iso8601 string.
Change-Id: I52ca7561abee158285c2c98ba63d84c62e12360f
-rw-r--r-- | keystoneclient/utils.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/keystoneclient/utils.py b/keystoneclient/utils.py index 67609e1..d71974b 100644 --- a/keystoneclient/utils.py +++ b/keystoneclient/utils.py @@ -114,7 +114,7 @@ def isotime(at=None, subsecond=False): if not subsecond else _ISO8601_TIME_FORMAT_SUBSECOND) tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC' - st += ('Z' if tz == 'UTC' else tz) + st += ('Z' if (tz == 'UTC' or tz == 'UTC+00:00') else tz) return st |