braintree / braintree_python

Braintree Python library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
242 stars 115 forks source link

ValueError in datetime.strptime #87

Closed petercgrant closed 7 years ago

petercgrant commented 7 years ago

Started receiving dispute webhook notifications today containing a datetime tag that fails to parse: <created-at type="datetime">2017-04-11T14:03:40+00:00</created-at>

The error ValueError: time data '2017-04-11T14:03:40+00:00' does not match format '%Y-%m-%dT%H:%M:%SZ' occurs at braintree/util/parser.py:41

The value is a valid ISO8601 datetime, but parsing fails at the timezone (expected: Z, actual: +00:00). strptime does not support proper parsing of ISO8601 datetime formats and has trouble with timezones in particular. Even with the addition of %z in Python 3, strptime does not properly parse the offset +00:00. Recommend using iso8601.parse_date or similar.

raymondberg commented 7 years ago

Hi, @petercgrant. Thanks for your diligence in reporting this! The issue you saw was due to a temporary change in date format in internal processing. The change was mitigated and this issue has been tested as no longer affecting the SDK. The intent is not to support this date format long-term, so changes to the library may not be necessary.

However, we appreciate the quick work on the PR. We're going to discuss internally to decide the best course of action regarding the flexibility of date processing in the SDK. Thank you for your efforts on #88 .