Sha256: 67af67fc3922f9449f807daac9f612f795213bc7d796036b74d83363e9aaa23c
Contents?: true
Size: 788 Bytes
Versions: 20
Compression:
Stored size: 788 Bytes
Contents
require "datagrid/filters/ranged_filter" class Datagrid::Filters::DateFilter < Datagrid::Filters::BaseFilter include RangedFilter def apply(grid_object, scope, value) if value.is_a?(Range) value = value.first.beginning_of_day..value.last.end_of_day end super(grid_object, scope, value) end def parse(value) Datagrid::Utils.parse_date(value) end def format(value) if formats.any? && value value.strftime(formats.first) else super end end def default_filter_where(driver, scope, value) if driver.is_timestamp?(scope, name) value = Datagrid::Utils.format_date_as_timestamp(value) end super(driver, scope, value) end protected def formats Array(Datagrid.configuration.date_formats) end end
Version data entries
20 entries across 20 versions & 1 rubygems