N3.js
N3.js copied to clipboard
Create Date literals?
Hi there,
What is the status with Date literals? Would it be possible to have javascript Date objects be recognised such that instead of currently:
> N3Util.createLiteral(new Date())
'"Thu Apr 27 2017 16:38:33 GMT+0200 (CEST)"'
We would have:
> N3Util.createLiteral(new Date())
'"2017-04-27T14:39:48.901Z"^^http://www.w3.org/2001/XMLSchema#dateTime'
Cheers!
Jun
Currently not supported indeed, but definitely nice to have!
For anyone stumbling upon this, I solved with:
literal(
new Date().toISOString(),
namedNode("http://www.w3.org/2001/XMLSchema#dateTime")
)
FYI, this tool may also be valuable: https://github.com/rubensworks/rdf-literal.js#converting-a-date
For anyone stumbling upon this, I solved with:
literal( new Date().toISOString(), namedNode("http://www.w3.org/2001/XMLSchema#dateTime") )
But is this correct according to https://www.w3.org/TR/rdf11-concepts/#dfn-recognized-datatype-iris#dfn-literal-term-equality? Since it results in ^^<http://www.w3.org/2001/XMLSchema#dateTime> and not in ^^http://www.w3.org/2001/XMLSchema#dateTime or in ^^<xsd:Date> instead of ^^xsd:Date, where the latter is the spec syntax.
Since it results in
^^<http://www.w3.org/2001/XMLSchema#dateTime>and not in^^http://www.w3.org/2001/XMLSchema#dateTimeor^^<xsd:Date>instead of^^xsd:Dateas specified.
?
The spec does not include the <...> in the literal type as far as I understand it
That's just syntax; it's all right.