From 8bc1186ce0a25e8d67c942649819b0edff52e545 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 24 Nov 2021 21:35:37 +0800 Subject: Use dateutil to parse jForm date Because jForm trims trailing 0's from milliseconds and Python's standard datetime.datetime.fromisoformat doesn't like that --- jimbrella/jform.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'jimbrella/jform.py') diff --git a/jimbrella/jform.py b/jimbrella/jform.py index e9f2a50..dc9d769 100644 --- a/jimbrella/jform.py +++ b/jimbrella/jform.py @@ -1,7 +1,7 @@ import requests import json from pathlib import Path -from datetime import datetime +from dateutil.parser import isoparse class JForm: @@ -108,6 +108,7 @@ class JForm: # when we exceed the total pages of a questionnaire # instead it just returns 200 along with an empty data field break + for sheet in sheets: if sheet["id"] <= bookmark: # is bookmark or earlier than bookmark @@ -121,7 +122,7 @@ class JForm: "id": ans[1]["answer"], "phone": ans[2]["answer"], "key": int(ans[3]["answer"]), - "date": datetime.fromisoformat(sheet["submitted_at"]), + "date": isoparse(sheet["submitted_at"]), } ) page += 1 -- cgit v1.2.3