From fd5829f8d29baf921250de866b7b3e3d5e4a1588 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 13 Nov 2021 10:45:46 +0000 Subject: [PATCH] Accept precision=7 (century) for time format --- matcher/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/matcher/utils.py b/matcher/utils.py index 9581ea4..d74701e 100644 --- a/matcher/utils.py +++ b/matcher/utils.py @@ -175,7 +175,10 @@ def format_wikibase_time(v): p = v["precision"] t = v["time"] - assert p in (9, 10, 11) + assert p in (7, 9, 10, 11) + + # TODO: handle dates with century precision (7) + # example: https://www.wikidata.org/wiki/Q108266998 if p == 11: return date.fromisoformat(t[1:11]).strftime("%d %B %Y") @@ -183,3 +186,5 @@ def format_wikibase_time(v): return date.fromisoformat(t[1:8] + "-01").strftime("%B %Y") if p == 9: return t[1:5] + if p == 7: + return t[1:5]