Module: Sunspot::Type::TimeType

Defined in:
lib/sunspot/type.rb

Overview

The time type represents times. Note that times are always converted to UTC before indexing, and facets of Time fields always return times in UTC.

Class Method Summary collapse

Class Method Details

.cast(string) ⇒ Object



113
114
115
# File 'lib/sunspot/type.rb', line 113

def cast(string)
  Time.xmlschema(string)
end

.indexed_name(name) ⇒ Object



102
103
104
# File 'lib/sunspot/type.rb', line 102

def indexed_name(name)
"#{name}_d"
end

.to_indexed(value) ⇒ Object



106
107
108
109
110
111
# File 'lib/sunspot/type.rb', line 106

def to_indexed(value)
  if value
    time = value.respond_to?(:to_time) ? value.to_time : Time.parse(value.to_s)
    time.utc.xmlschema
  end
end