Skip to content

Commit

Permalink
Fix date parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
janheinrichmerker committed Jan 14, 2023
1 parent 6696cbf commit e5f4ee2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion chatnoir_api/v1/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ class ExplainedMinimalResultResponseStaging(
explanation: ExplanationResponse


def _decode_datetime(value: Optional[str]) -> Optional[datetime]:
if value is None:
return None
return datetime.fromisoformat(value)


@dataclass(frozen=True)
class ResultResponseStaging(
MinimalResultResponseStaging, ResultResponse, ResultStaging,
Expand All @@ -125,7 +131,7 @@ class ResultResponseStaging(
warc_id: Optional[str]
cache_uri: Optional[str]
crawl_date: Optional[datetime] = field(metadata=config(
decoder=datetime.fromisoformat
decoder=_decode_datetime
))
content_type: str
language: str = field(metadata=config(field_name="lang"))
Expand Down

0 comments on commit e5f4ee2

Please sign in to comment.