Accept precision=7 (century) for time format

This commit is contained in:
Edward Betts 2021-11-13 10:45:46 +00:00
parent b22d4058fd
commit fd5829f8d2

View file

@ -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]