-
Notifications
You must be signed in to change notification settings - Fork 577
Description
Literal values which represent dates or years before BCE (ie negative years) are no longer supported due to limitations of the newly added isodate dependency. This is a regression with the previous behaviour.
I assume that the project is using the isodate package, yet that package explicitly mentions that it does not support negative values:
[...] it is not possible to convert all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are not allowed [...]
Example:
import rdflib
year = rdflib.Literal("-0001", datatype=rdflib.namespace.XSD.gYear)
Failed to convert Literal lexical form to value. Datatype=http://www.w3.org/2001/XMLSchema#gYear, Converter=<function parse_date at 0x7f28d3830d30>
Traceback (most recent call last):
File "/data/projects/mrgcn/python310venv/lib/python3.10/site-packages/rdflib/term.py", line 2084, in _castLexicalToPython
return conv_func(lexical) # type: ignore[arg-type]
File "/data/projects/mrgcn/python310venv/lib/python3.10/site-packages/isodate/isodates.py", line 203, in parse_date
raise ISO8601Error('Unrecognised ISO 8601 date format: %r' % datestring)
isodate.isoerror.ISO8601Error: Unrecognised ISO 8601 date format: '-0001
Excepted behaviour:
I expect all values that comply with the Seven-Property-Model or the ISO 8601 standard to be supported. This includes all positive years from 0001 to 9999 and all negative years from -0001 to -9999, and all dates that specify those years.
Possible solution:
Since RDF enjoys a large adoption in historical domains I think it is unacceptable to exclude dates before BCE. Yet I understand that you want to wrap dates to make processing them by users more convenient. I therefore suggest to add a parameter to_python=[T|F]
to the parser to enable users to make this decision for themselves whether they want to convert their literal values to internal Python constructs. Libraries like NumPy already do something similar. This also solves the loss of accuracy with numbers such as "001", which get converted to just "1".