dahlia / wikidata

Wikidata client library for Python
https://pypi.org/project/Wikidata/
GNU General Public License v3.0
337 stars 31 forks source link

Except 7: time precision other than 9, 11 or 14 is unsupported wikidata #58

Closed BaptisteBayche closed 2 months ago

BaptisteBayche commented 2 months ago

Hi,

When I try to get a date with a precision level of 7, I encounter this error: 7: time precision other than 9, 11 or 14 is unsupported wikidata {'type': 'time', 'value': {'time': '+2000-00-00T00:00:00Z', 'timezone': 0, 'before': 0, 'after': 0, 'precision': 7, 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727'}} (see https://www.wikidata.org/wiki/Q111534373 for this example) This error occurs because precision level 7 is unsupported. However, is it possible to add support for precision 7 in datavalue.py?

I propose adding the following code at line 201:

if precision == 7:
  return int(time[1:3])

Thank you

dahlia commented 2 months ago

That's a good idea! If you open a pull request, I'm going to review it as soon as possible.