Skip to content

Commit d9c0da8

Browse files
committed
improve date parsing
1 parent 444174d commit d9c0da8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jsonschema/_format.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ def is_regex(instance):
330330
def is_date(instance):
331331
if not isinstance(instance, str):
332332
return True
333-
return datetime.datetime.strptime(instance, "%Y-%m-%d")
333+
try:
334+
return datetime.date.fromisoformat(instance)
335+
except AttributeError:
336+
return datetime.datetime.strptime(instance, "%Y-%m-%d")
334337

335338

336339
@_checks_drafts(draft3="time", raises=ValueError)

0 commit comments

Comments
 (0)