Skip to content

Commit 29ca99f

Browse files
Merge pull request openMetadataInitiative#65 from apdavison/forgiving-date-handling
Allow a datetime string to be provided for a property with type "date"
2 parents f2fcf2a + ddd610b commit 29ca99f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pipeline/src/properties.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ def deserialize_item(item):
202202
elif datetime in self.types:
203203
return datetime.fromisoformat(item)
204204
elif date in self.types:
205-
return date.fromisoformat(item)
205+
try:
206+
return date.fromisoformat(item)
207+
except ValueError as err:
208+
# if a datetime string has been provided
209+
# take the date part.
210+
try:
211+
return datetime.fromisoformat(item).date()
212+
except ValueError:
213+
raise err
206214
elif all(issubclass(t, Node) for t in self.types):
207215
# use data["@type"] to figure out class to use
208216
if "@type" in item:

0 commit comments

Comments
 (0)