class Elastic::Datatypes::Time

Public Instance Methods

date_histogram_aggregation_defaults() click to toggle source
# File lib/elastic/datatypes/time.rb, line 25
def date_histogram_aggregation_defaults
  { interval: '1h', time_zone: time_zone }
end
mapping_options() click to toggle source
# File lib/elastic/datatypes/time.rb, line 3
def mapping_options
  options = super
  options[:type] = 'date'
  options
end
prepare_value_for_result(_value) click to toggle source
# File lib/elastic/datatypes/time.rb, line 9
def prepare_value_for_result(_value)
  # TODO: set timezone
  case _value
  when ::String
    time_zone.parse(_value)
  when ::Integer
    time_zone.at(_value / 1000)
  else
    _value
  end
end
supported_aggregations() click to toggle source
# File lib/elastic/datatypes/time.rb, line 21
def supported_aggregations
  [:date_histogram] + super
end

Private Instance Methods

time_zone() click to toggle source
# File lib/elastic/datatypes/time.rb, line 31
def time_zone
  # TODO: user_options[:timezone]
  Elastic.config.time_zone
end