Skip to content

Commit

Permalink
Handle Case When Call To Next Event Returns None
Browse files Browse the repository at this point in the history
  • Loading branch information
alvindera97 committed Apr 9, 2022
1 parent 115af08 commit aa4d55b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,17 @@ def next_time(self):
return None

def is_scheduled_to_start_this_year(self) -> bool:
current_year: int = datetime.datetime.now().year
try:
if self.next_time:
current_year: int = datetime.datetime.now().year
if self.next_time.dt_start.year == current_year:
return True
except Exception:
pass
return False

def is_scheduled_to_end_this_year(self) -> bool:
current_year: int = datetime.datetime.now().year
try:
if self.next_time:
current_year: int = datetime.datetime.now().year
if self.next_time.dt_end.year == current_year:
return True
except Exception:
pass
return False

@property
Expand Down

0 comments on commit aa4d55b

Please sign in to comment.