Sha256: 971f8def2c784fd999e9b3b7851e86640d0e1ab336a064a8dfafd52f7e42930e

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

module RDF::N3::Algebra::Time
  ##
  # For a date-time format string, its time:localTime is the result of formatting the current time of processing and local timezone in the format given. If the format string has zero length, then the ISOdate standrad format is used.  [ is time:localTime of ""]  the therefore the current date time. It will end with a numeric timezone code or "Z" for UTC (GMT).
  #
  # @see https://www.w3.org/TR/xpath-functions/#func-current-dateTime
  class LocalTime < RDF::N3::Algebra::ResourceOperator
    NAME = :timeLocalTime
    URI = RDF::N3::Time.localTime

    ##
    # The time:localTime operator takes string or dateTime and returns current time formatted according to the subject.
    #
    # @param [RDF::Term] resource
    # @param [:subject, :object] position
    # @return [RDF::Term]
    # @see RDF::N3::ResourceOperator#evaluate
    def resolve(resource, position:)
      case position
      when :subject
        return nil unless resource.literal?
        resource = "%FT%T%:z" if resource.to_s.empty?
        RDF::Literal(DateTime.now.strftime(resource.to_s))
      when :object
        return nil unless resource.literal? || resource.variable?
        resource
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-n3-3.3.0 lib/rdf/n3/algebra/time/local_time.rb
rdf-n3-3.2.1 lib/rdf/n3/algebra/time/local_time.rb
rdf-n3-3.2.0 lib/rdf/n3/algebra/time/local_time.rb
rdf-n3-3.1.2 lib/rdf/n3/algebra/time/local_time.rb