Skip to content

Commit

Permalink
Fix netology error
Browse files Browse the repository at this point in the history
  • Loading branch information
depocoder committed Dec 4, 2024
1 parent 3229016 commit b8ec12e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/yet_another_calendar/web/api/netology/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,21 @@ def exclude_attachment(self) -> list[ExtendedLesson]:
class DetailedProgram(BaseModel):
id: int
name: str
start_date: datetime.datetime
finish_date: datetime.datetime
start_date: Optional[datetime.datetime] = Field(default=None)
finish_date: Optional[datetime.datetime] = Field(default=None)

@field_validator("start_date")
@classmethod
def validate_start_date(cls, start_date: datetime.datetime) -> datetime.datetime:
def validate_start_date(cls, start_date: Optional[datetime.datetime]) -> Optional[datetime.datetime]:
if start_date is None:
return start_date
return start_date.astimezone(datetime.timezone.utc)

@field_validator("finish_date")
@classmethod
def validate_finish_date(cls, finish_date: datetime.datetime) -> datetime.datetime:
def validate_finish_date(cls, finish_date: Optional[datetime.datetime]) -> Optional[datetime.datetime]:
if finish_date is None:
return finish_date
return finish_date.astimezone(datetime.timezone.utc)


Expand Down

0 comments on commit b8ec12e

Please sign in to comment.