class RDF::N3::Algebra::Time::InSeconds
Iff the subject is a ‘xsd:dateTime` and the object is the integer number of seconds since the beginning of the era on a given system. Don’t assume a particular value, always test for it. The object can be calculated as a function of the subject.
@see www.w3.org/TR/xpath-functions/#func-timezone-from-dateTime
Constants
- NAME
- URI
Public Instance Methods
input_operand()
click to toggle source
Return both subject and object operands.
@return [RDF::Term]
# File lib/rdf/n3/algebra/time/in_seconds.rb, line 54 def input_operand RDF::N3::List.new(values: operands) end
resolve(resource, position:)
click to toggle source
The time:inseconds operator takes may have either a bound subject or object.
@param [RDF::Term] resource @param [:subject, :object] position @return [RDF::Term] @see RDF::N3::ResourceOperator#evaluate
# File lib/rdf/n3/algebra/time/in_seconds.rb, line 17 def resolve(resource, position:) case position when :subject case resource when RDF::Query::Variable resource when RDF::Literal # Subject evaluates to seconds from the epoc RDF::Literal::Integer.new(resource.as_datetime.object.strftime("%s")) else nil end when :object case resource when RDF::Query::Variable resource when RDF::Literal resource = resource.as_number # Object evaluates to the DateTime representation of the seconds form the epoc RDF::Literal(RDF::Literal::DateTime.new(::Time.at(resource).utc.to_datetime).to_s) else nil end end end
valid?(subject, object)
click to toggle source
Either subject or object must be a bound resource
# File lib/rdf/n3/algebra/time/in_seconds.rb, line 44 def valid?(subject, object) return true if subject.literal? || object.literal? log_error(NAME) {"subject or object are not literals: #{subject.inspect}, #{object.inspect}"} false end