Class: Sunspot::Type::DateType
- Inherits:
-
TimeType
- Object
- AbstractType
- TimeType
- Sunspot::Type::DateType
- Defined in:
- lib/sunspot/type.rb
Overview
The DateType encapsulates dates (without time information). Internally, Solr does not have a date-only type, so this type indexes data using Solr’s DateField type (which is actually date/time), midnight UTC of the indexed date.
Constant Summary
Constants inherited from TimeType
Instance Method Summary collapse
-
#cast(string) ⇒ Object
:nodoc:.
-
#to_indexed(value) ⇒ Object
:nodoc:.
Methods inherited from TimeType
Methods inherited from AbstractType
#accepts_dynamic?, #accepts_more_like_this?, #to_literal
Instance Method Details
#cast(string) ⇒ Object
:nodoc:
263 264 265 266 |
# File 'lib/sunspot/type.rb', line 263 def cast(string) #:nodoc: time = super Date.civil(time.year, time.mon, time.mday) end |
#to_indexed(value) ⇒ Object
:nodoc:
250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/sunspot/type.rb', line 250 def to_indexed(value) #:nodoc: if value time = if %w(year mon mday).all? { |method| value.respond_to?(method) } Time.utc(value.year, value.mon, value.mday) else date = Date.parse(value.to_s) Time.utc(date.year, date.mon, date.mday) end super(time) end end |