From 1ad516c6e8ceb2ef07e6510e8a9eb5331c40b3cf Mon Sep 17 00:00:00 2001 From: Jessica Smith <12jessicasmith34@gmail.com> Date: Tue, 7 Jan 2025 16:25:20 -0600 Subject: [PATCH] check for start/end date being set after the fact to datetime --- src/otf_api/filters.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/otf_api/filters.py b/src/otf_api/filters.py index 1a5c665..208e599 100644 --- a/src/otf_api/filters.py +++ b/src/otf_api/filters.py @@ -1,4 +1,4 @@ -from datetime import date, time +from datetime import date, datetime, time from pydantic import BaseModel, field_validator @@ -43,6 +43,13 @@ def filter_classes(self, classes: list[OtfClass]) -> list[OtfClass]: Returns: list[OtfClass]: The filtered list of classes. """ + # in case these are set after the class is created + if self.start_date and isinstance(self.start_date, datetime): + self.start_date = self.start_date.date() + + if self.end_date and isinstance(self.end_date, datetime): + self.end_date = self.end_date.date() + if self.start_date: classes = [c for c in classes if c.starts_at_local.date() >= self.start_date]