N3.js icon indicating copy to clipboard operation
N3.js copied to clipboard

Create Date literals?

Open jmatsushita opened this issue 7 years ago • 7 comments

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

jmatsushita avatar Apr 27 '17 14:04 jmatsushita

Currently not supported indeed, but definitely nice to have!

RubenVerborgh avatar Apr 27 '17 15:04 RubenVerborgh

For anyone stumbling upon this, I solved with:

literal(
  new Date().toISOString(),
  namedNode("http://www.w3.org/2001/XMLSchema#dateTime")
)

belvederef avatar Oct 06 '20 16:10 belvederef

FYI, this tool may also be valuable: https://github.com/rubensworks/rdf-literal.js#converting-a-date

rubensworks avatar Oct 07 '20 06:10 rubensworks

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.

ManuelTS avatar Jan 17 '22 13:01 ManuelTS

Since it results in ^^<http://www.w3.org/2001/XMLSchema#dateTime> and not in ^^http://www.w3.org/2001/XMLSchema#dateTime or ^^<xsd:Date> instead of ^^xsd:Date as specified.

?

RubenVerborgh avatar Jan 17 '22 13:01 RubenVerborgh

The spec does not include the <...> in the literal type as far as I understand it

ManuelTS avatar Jan 17 '22 13:01 ManuelTS

That's just syntax; it's all right.

RubenVerborgh avatar Jan 17 '22 13:01 RubenVerborgh