Skip to content

Commit 2e0a42f

Browse files
authored
{Core} Fix _normalize_expires_on on Python 3.6 (#20874)
1 parent 02edd22 commit 2e0a42f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/azure-cli-core/azure/cli/core/auth/adal_authentication.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ def _normalize_expires_on(expires_on):
9292
expires_on_epoch_int = int(expires_on)
9393
except ValueError:
9494
import datetime
95+
96+
# Python 3.6 doesn't recognize timezone as +00:00.
97+
# These lines can be dropped after Python 3.6 is dropped.
98+
# https://stackoverflow.com/questions/30999230/how-to-parse-timezone-with-colon
99+
if expires_on[-3] == ":":
100+
expires_on = expires_on[:-3] + expires_on[-2:]
101+
95102
# Treat as datetime string "11/05/2021 15:18:31 +00:00"
96103
expires_on_epoch_int = int(datetime.datetime.strptime(expires_on, '%m/%d/%Y %H:%M:%S %z').timestamp())
97104

0 commit comments

Comments
 (0)