Open jstirnaman opened 12 years ago
Oh, and, irb(main):020:0> d = RDF::Literal::DateTime.new('2012-05-11 21:07:50 UTC') => #<RDF::Literal::DateTime:0x189282c("2012-05-11 21:07:50 UTC"^^http://www.w3.org/2001/XMLSchema#dateTime)> irb(main):021:0> d.valid? => false
These work. The iso8601 method is maybe clearer. Preference? (DateTime.parse('2012-05-11 21:07:50 UTC')) (DateTime.parse('2012-05-11 21:07:50 UTC').iso8601) # => "2012-05-11T21:07:50+00:00"
They replace the UTC time with the offset-from-UTC-time.
irb(main):025:0> RDF::Literal::DateTime.new(DateTime.parse('2012-05-11 21:07:50 UTC')).valid? => true irb(main):026:0> RDF::Literal::DateTime.new(DateTime.parse('2012-05-11 21:07:50 UTC').iso8601).valid? => true
gah, .iso8601 is not in 1.8.7, though. DateTime.parse or strftime() do the same in 1.8.7.
irb(main):028:0> RDF::Literal::DateTime.new(DateTime.parse('2012-05-11 21:07:50 UTC').strftime).valid? => true irb(main):029:0> DateTime.parse('2012-05-11 21:07:50 UTC').strftime => "2012-05-11T21:07:50+00:00" irb(main):030:0>
_package.rdf.builder renders work.created_at and work.update_at in RDF, declaring these values are rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime"
However, the values rendered don't conform to xsd.datetime. They should look like '2012-05-11T21:07:50Z', as described in http://www.w3schools.com/schema/schema_dtypes_date.asp
To verify here's some output from the ruby-rdf gem: irb(main):014:0> d = RDF::Literal::DateTime.new(' 2012-05-11 21:07:50 UTC') => #<RDF::Literal::DateTime:0x16bb31c(" 2012-05-11 21:07:50 UTC"^^http://www.w3.org/2001/XMLSchema#dateTime)> irb(main):015:0> d.valid? => false irb(main):016:0> d = RDF::Literal::DateTime.new(' 2012-05-11T21:07:50Z') => #<RDF::Literal::DateTime:0x187ae14(" 2012-05-11T21:07:50Z"^^http://www.w3.org/2001/XMLSchema#dateTime)> irb(main):017:0> d.valid? => false irb(main):018:0> d = RDF::Literal::DateTime.new('2012-05-11T21:07:50Z') => #<RDF::Literal::DateTime:0x1849c68("2012-05-11T21:07:50Z"^^http://www.w3.org/2001/XMLSchema#dateTime)> irb(main):019:0> d.valid? => true
One last note, I didn't encounter the validation error when using ruby-rdf and Ruby 1.9.2 to load the BibApp RDF into a graph, but I did when using Ruby 1.9.3. I haven't explored differences between them.
I'll submit a patch for this soon.