Skip to content

Commit

Permalink
Fix validation errors in Notes
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Sep 22, 2024
1 parent 0b1dd70 commit f55c789
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions genshin/models/genshin/chronicle/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class Expedition(APIModel):
status: typing.Literal["Ongoing", "Finished"]
remaining_time: datetime.timedelta = Aliased("remained_time")

@pydantic.field_validator("remaining_time", mode="before")
def __process_timedelta(cls, v: str) -> datetime.timedelta:
return datetime.timedelta(seconds=int(v))

@property
def finished(self) -> bool:
"""Whether the expedition has finished."""
Expand Down Expand Up @@ -191,6 +195,10 @@ class Notes(APIModel):

archon_quest_progress: ArchonQuestProgress

@pydantic.field_validator("remaining_resin_recovery_time", "remaining_realm_currency_recovery_time", mode="before")
def __process_timedelta(cls, v: str) -> datetime.timedelta:
return datetime.timedelta(seconds=int(v))

@property
def resin_recovery_time(self) -> datetime.datetime:
"""The time when resin will be recovered."""
Expand Down

0 comments on commit f55c789

Please sign in to comment.