Skip to content

Commit 850a346

Browse files
Arthur Dingemansgkellogg
authored andcommitted
A Time should be typed as XMLSchema#dateTime
Ruby does not have a class which represents a time without date. A Tod::TimeOfDay provided by the `tod` gem would justify XMLSchema#time, but the default Time class always includes a Date.
1 parent a7f2ec7 commit 850a346

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/rdf/model/literal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def self.new(value, language: nil, datatype: nil, lexical: nil, validate: false,
119119
when ::Float then RDF::Literal::Double
120120
when ::BigDecimal then RDF::Literal::Decimal
121121
when ::DateTime then RDF::Literal::DateTime
122+
when ::Time then RDF::Literal::DateTime
122123
when ::Date then RDF::Literal::Date
123-
when ::Time then RDF::Literal::Time # FIXME: Ruby's Time class can represent datetimes as well
124124
when ::Symbol then RDF::Literal::Token
125125
else self
126126
end

spec/model_literal_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def self.literals(*selector)
138138
3.1415 => "double",
139139
Date.new(2010) => "date",
140140
DateTime.new(2011) => "dateTime",
141-
Time.parse("01:02:03Z") => "time"
141+
Time.parse("01:02:03Z") => "dateTime"
142142
}.each_pair do |value, type|
143143
it "returns xsd.#{type} for #{value.inspect} #{value.class}" do
144144
expect(RDF::Literal.new(value).datatype).to eq XSD[type]
@@ -217,7 +217,7 @@ def self.literals(*selector)
217217
literal(:double) => "3.1415",
218218
literal(:date) => "2010-01-01",
219219
literal(:datetime) => "2011-01-01T00:00:00Z",
220-
literal(:time) => "01:02:03Z"
220+
literal(:time) => "#{Date.today}T01:02:03Z"
221221
}.each_pair do |args, rep|
222222
it "returns #{rep} for #{args.inspect}" do
223223
literal = RDF::Literal.new(*args)

0 commit comments

Comments
 (0)