Add strptime() hack for older systems (?)

not actually sure what the issue is there, but this works..
This commit is contained in:
Lance Edgar 2021-11-08 14:11:45 -06:00
parent 8d858d74bd
commit a997ffc7bb

View file

@ -59,6 +59,14 @@ class FromMailChimp(importing.Importer):
self.mailchimp = MailChimp(self.api_key) self.mailchimp = MailChimp(self.api_key)
def mailchimp_datetime(self, value): def mailchimp_datetime(self, value):
if value.endswith('+00:00'):
# TODO: for some reason the '%z' format did not work on a
# python 3.5 system, so here we try to ignore the
# issue..since we clearly have a UTC value
value = value[:-6]
dt = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
dt = localtime(self.config, dt, from_utc=True)
else:
dt = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S%z') dt = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S%z')
dt = localtime(self.config, dt) dt = localtime(self.config, dt)
return dt return dt