Skip to content

Commit

Permalink
Merge pull request #652 from nationalarchives/fix/handle-unparseable-…
Browse files Browse the repository at this point in the history
…dates

If a date from the database is unparseable, use the raw string
  • Loading branch information
jacksonj04 authored Apr 21, 2023
2 parents 6c6126d + d7b6ed3 commit 213b714
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion judgments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from caselawclient.Client import api_client
from dateutil import parser as dateparser
from dateutil.parser import ParserError
from django.db import models
from djxml import xmlmodels
from ds_caselaw_utils.courts import CourtNotFoundException, courts
Expand All @@ -25,7 +26,11 @@ def __init__(
self.uri = uri
self.neutral_citation = neutral_citation
self.name = name
self.date = dateparser.parse(date)

try:
self.date = dateparser.parse(date)
except ParserError:
self.date = date
try:
self.court = courts.get_by_code(court)
except CourtNotFoundException:
Expand Down

0 comments on commit 213b714

Please sign in to comment.