How to parse timezone with colon

Currently, there is no cure for this, and here is and explanation: https://bugs.python.org/issue15873 more precisely, here: https://bugs.python.org/msg169952 .
But you can override this issue, this way:

from datetime import datetime
d = "2015-04-30T23:59:59+00:00"
if ":" == d[-3:-2]:
    d = d[:-3]+d[-2:]
print(datetime.strptime(d, "%Y-%m-%dT%H:%M:%S%z"))

Leave a Comment

tech