Skip to content

Commit

Permalink
fix: removes dates that fail the dateparsing
Browse files Browse the repository at this point in the history
python does not allow for dates prior 0000. to allow for that we need
to move to another library. For the moment we remove dates that fail
to parse

fixes #165
  • Loading branch information
sennierer committed Jun 26, 2023
1 parent 4062728 commit 1243fff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion intavia_backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def flatten_rdf_data(data: dict) -> list:
if "value" in v:
if "datatype" in v:
if v["datatype"] == "http://www.w3.org/2001/XMLSchema#dateTime":
v["value"] = datetime.datetime.fromisoformat(str(v["value"]).replace("Z", "+00:00"))
try:
v["value"] = datetime.datetime.fromisoformat(str(v["value"]).replace("Z", "+00:00"))
except ValueError:
continue # FIXME: this is removing dates before 0, should be fixed
elif v["datatype"] == "http://www.w3.org/2001/XMLSchema#integer":
v["value"] = int(v["value"])
elif v["datatype"] == "http://www.w3.org/2001/XMLSchema#boolean":
Expand Down

0 comments on commit 1243fff

Please sign in to comment.