Skip to content

Commit

Permalink
Make ShiyuDefense begin_time and end_time Optional (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
Polygonalr authored Aug 4, 2024
1 parent 20067d5 commit c34f63d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions genshin/models/zzz/chronicle/challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class ShiyuDefense(APIModel):
"""ZZZ Shiyu Defense model."""

schedule_id: int
begin_time: datetime.datetime = Aliased("hadal_begin_time")
end_time: datetime.datetime = Aliased("hadal_end_time")
begin_time: typing.Optional[datetime.datetime] = Aliased("hadal_begin_time")
end_time: typing.Optional[datetime.datetime] = Aliased("hadal_end_time")
has_data: bool
ratings: typing.Mapping[typing.Literal["S", "A", "B"], int] = Aliased("rating_list")
floors: typing.List[ShiyuDefenseFloor] = Aliased("all_floor_detail")
Expand All @@ -133,8 +133,10 @@ def __convert_ratings(
@pydantic.validator("begin_time", "end_time", pre=True)
@classmethod
def __add_timezone(
cls, v: typing.Dict[typing.Literal["year", "month", "day", "hour", "minute", "second"], int]
) -> datetime.datetime:
return datetime.datetime(
v["year"], v["month"], v["day"], v["hour"], v["minute"], v["second"], tzinfo=CN_TIMEZONE
)
cls, v: typing.Optional[typing.Dict[typing.Literal["year", "month", "day", "hour", "minute", "second"], int]]
) -> typing.Optional[datetime.datetime]:
if v is not None:
return datetime.datetime(
v["year"], v["month"], v["day"], v["hour"], v["minute"], v["second"], tzinfo=CN_TIMEZONE
)
return None

0 comments on commit c34f63d

Please sign in to comment.