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

:nodoc:



119
120
121
# File 'lib/sunspot/type.rb', line 119

def cast(string) #:nodoc:
  Time.xmlschema(string)
end

.indexed_name(name) ⇒ Object

:nodoc:



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

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

.to_indexed(value) ⇒ Object

:nodoc:



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/sunspot/type.rb', line 107

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