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:



123
124
125
# File 'lib/sunspot/type.rb', line 123

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

.indexed_name(name) ⇒ Object

:nodoc:



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

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

.to_indexed(value) ⇒ Object

:nodoc:



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/sunspot/type.rb', line 111

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