Sha256: e165a834301c46d00c2276c25c0c5cd5e56a0fdaa311740db0bddb79a94fdf33

Contents?: true

Size: 697 Bytes

Versions: 31

Compression:

Stored size: 697 Bytes

Contents

module Searchlogic
  class Search
    module DateParts
      def conditions=(values)
        values.clone.each do |condition, value|
          # if a condition name ends with "(1i)", assume it's date / datetime
          if condition =~ /(.*)\(1i\)$/
            date_scope_name = $1
            date_parts = (1..6).to_a.map do |idx|
              values.delete("#{ date_scope_name }(#{ idx }i)")
            end.reject{|s| s.blank? }.map{|s| s.to_i }

            # did we get enough info to build a time?
            if date_parts.length >= 3
              values[date_scope_name] = Time.zone.local(*date_parts)
            end
          end
        end
        super
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 4 rubygems

Version Path
searchlogic-2.5.19 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.18 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.17 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.16 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.15 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.14 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.13 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.12 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.11 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.10 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.9 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.8 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.7 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.6 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.5 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.4 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.3 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.2 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.1 lib/searchlogic/search/date_parts.rb
searchlogic-2.5.0 lib/searchlogic/search/date_parts.rb