Skip to content

Commit 0cdfa43

Browse files
committed
compare lineitem times as datetime objects
Canvas was returning the start time with the summertime offset, but the local time was at UTC+0. They should be considered equivalent.
1 parent c3a5fea commit 0cdfa43

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

numbas_lti/models.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,18 @@ def get_lti_13_lineitem(self, create = False):
848848

849849
saved_lineitem = LineItem(saved_lineitem)
850850

851+
def parse_isoformat(time: str):
852+
if time is None:
853+
return None
854+
return datetime.fromisoformat(time)
855+
851856
if (saved_lineitem.get_score_maximum() != lineitem.get_score_maximum()
852-
or saved_lineitem.get_start_date_time() != lineitem.get_start_date_time()
853-
or saved_lineitem.get_end_date_time() != lineitem.get_end_date_time()
857+
or parse_isoformat(saved_lineitem.get_start_date_time()) != parse_isoformat(lineitem.get_start_date_time())
858+
or parse_isoformat(saved_lineitem.get_end_date_time()) != parse_isoformat(lineitem.get_end_date_time())
854859
or saved_lineitem.get_tag() != lineitem.get_tag()
855860
):
856861
max_score = lineitem.get_score_maximum()
862+
857863
if max_score is not None and max_score > 0:
858864
saved_lineitem.set_score_maximum(max_score)
859865
saved_lineitem.set_start_date_time(lineitem.get_start_date_time())

0 commit comments

Comments
 (0)