{"action":"opened","issue":{"number":45,"created_at":"2011-10-19T01:04:58Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Originally filed by ed.summers on 2009-02-17T10:55:06\n\nIt's nice that toPython() will convert dateTime XSD datatypes to datetime python objects:\r\n\r\n>>> from rdflib import Literal , Namespace\r\n>>> from datetime import datetime\r\n>>> XSD_NS = Namespace(u'http://www.w3.org/2001/XMLSchema#')\r\n>>> Literal('2008-02-09T10:46:29', datatype=XSD_NS.dateTime).toPython()\r\ndatetime.datetime(2008, 2, 9, 10, 46, 29)\r\n\r\nBut if you add milliseconds it doesn't seem to work:\r\n\r\n>>> Literal('2009-02-17T05:48:53.203307', datatype=XSD_NS.dateTime).toPython()\r\nrdflib.Literal('2009-02-17T05:48:53.203307', language=None, \r\ndatatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))\r\n\r\nThis bit me recently when I couldn't figure out why adding triples with datetime.now() wasn't \r\nworking as expected:\r\n\r\n>>> Literal(datetime.now()).toPython()\r\nrdflib.Literal('2009-02-17T05:52:13.612998', language=None, \r\ndatatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))\r\n\r\nIt appears that RDFAlchemy had to hack around this problem: \r\nhttp://www.openvest.com/trac/wiki/CustomizingLiterals","comments":0,"title":"toPython() doesn't convert datetimes with millis","updated_at":"2011-10-19T01:04:58Z","url":"https://api.github.com/repos/gjhiggins/rdflib/issues/45","id":1989445,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/918398787dc9e085672703644972e5e4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"918398787dc9e085672703644972e5e4","url":"https://api.github.com/users/gjhiggins","id":16417,"login":"gjhiggins"},"html_url":"https://github.com/gjhiggins/rdflib/issues/45","labels":[],"state":"open"},"legacy":{"number":45,"action":"opened","issue":1989445}}