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
-
.cast(string) ⇒ Object
:nodoc:.
-
.indexed_name(name) ⇒ Object
:nodoc:.
-
.to_indexed(value) ⇒ Object
:nodoc:.
Class Method Details
.cast(string) ⇒ Object
:nodoc:
121 122 123 |
# File 'lib/sunspot/type.rb', line 121 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 118 119 |
# File 'lib/sunspot/type.rb', line 107 def to_indexed(value) #:nodoc: if value time = if value.respond_to?(:utc) value elsif %w(year mon mday).each { |method| value.respond_to?(method) } Time.gm(value.year, value.mon, value.mday) else Time.parse(value.to_s) end time.utc.xmlschema end end |