Merge pull request #83 from codl/1.1.0-fix-log-in

fix exception in log_in, by accepting json dates as timestamps
This commit is contained in:
Lorenz Diener 2017-09-10 17:00:27 +02:00 cometido por GitHub
commit bd855a931c

Veure arxiu

@ -973,7 +973,10 @@ class Mastodon:
for k, v in json_object.items(): for k, v in json_object.items():
if k in known_date_fields: if k in known_date_fields:
try: try:
json_object[k] = dateutil.parser.parse(v) if isinstance(v, int):
json_object[k] = datetime.datetime.fromtimestamp(v, pytz.utc)
else:
json_object[k] = dateutil.parser.parse(v)
except: except:
raise MastodonAPIError('Encountered invalid date.') raise MastodonAPIError('Encountered invalid date.')
return json_object return json_object