Skip to content

Commit

Permalink
add more validation
Browse files Browse the repository at this point in the history
  • Loading branch information
depocoder committed Oct 24, 2024
1 parent 7fd165e commit 8a6d04d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backend/yet_another_calendar/web/api/netology/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def deadline_validation(cls, data: Any) -> Any:
match = re.search(_DATE_PATTERN, data.get('title', ''))
if not match:
return data
date = match.group(0)
data['deadline'] = datetime.datetime.strptime(date, "%d.%m.%y").astimezone(datetime.timezone.utc)
return data
try:
date = match.group(0).replace('00.', '01.')
data['deadline'] = datetime.datetime.strptime(date, "%d.%m.%y").astimezone(datetime.timezone.utc)
return data
except:
return data

def is_suitable_time(self, time_min: datetime.datetime, time_max: datetime.datetime) -> bool:
"""Check if lesson have suitable time"""
Expand Down

0 comments on commit 8a6d04d

Please sign in to comment.