Skip to content

Commit

Permalink
check for start/end date being set after the fact to datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
NodeJSmith committed Jan 7, 2025
1 parent 23ffa0d commit 1ad516c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/otf_api/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import date, time
from datetime import date, datetime, time

from pydantic import BaseModel, field_validator

Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit 1ad516c

Please sign in to comment.