-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rdflib.Literal
handling of timezone aware datetime objects
#2014
Comments
Not an unreasonable question at all but any implementation is going to be hampered by the fact that Python doesn't provide a There's another factor tilting the balance in favour of having to explicitly specify a datetimestamp datatype for a Literal - as Andy Seaborne notes wrt to a SO query on
Having grepped the RDFLib SPARQL source for ¹ AndyS recommends I'll leave this as an issue for a little while before converting it to a discussion entry. |
Thanks very much for the prompt reply!
I agree, and I thought about this when looking through the source code of Example
|
I'd like to hop in1 with another perspective favoring implementation rather than waiting. Some applications are picky with On a purely mechanical matter, SHACL constraints (particularly The mechanical matter could end up being significant to more users soon. The current Candidate Recommendation Draft of OWL-Time deprecates On a design matter, there are reasons to say why one might be used situationally versus the other. Some timelining applications have to start from timezoneless data, such as FAT file systems' timestamps, or database columns where the timezone was forgotten and then the database was migrated to a new geographic region. In these cases, getting to use On a bug matter, I just hit an unexpected behavior, which I think lines up with @gjhiggins 's report on current implementation status. >>> import rdflib
>>> x = rdflib.Literal("2023-01-01T01:23:45", datatype=rdflib.XSD.dateTime)
>>> x
rdflib.term.Literal('2023-01-01T01:23:45', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))
>>> x.toPython()
datetime.datetime(2023, 1, 1, 1, 23, 45)
>>> y = rdflib.Literal("2023-01-01T01:23:45", datatype=rdflib.XSD.dateTimeStamp)
>>> y
rdflib.term.Literal('2023-01-01T01:23:45', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTimeStamp'))
>>> y.toPython()
rdflib.term.Literal('2023-01-01T01:23:45', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTimeStamp')) Two issues:
So, I think support for this datatype is worth pursuit. Footnotes
|
Hi,
Currently, timezone aware and unaware datetimes are both assigned the datatype
xsd:dateTime
by default if no datatype is specified.(See: https://github.com/RDFLib/rdflib/blob/6.1.1/rdflib/term.py#L1579)
My question is, would it be more appropriate default behaviour for an unaware datetime to be assigned
xsd:dateTime
and aware datetimes to be assignedxsd:dateTimeStamp
?Example
Thanks!
The text was updated successfully, but these errors were encountered: