class Datagrid::Filters::DateFilter

Public Instance Methods

apply(grid_object, scope, value) click to toggle source
Calls superclass method Datagrid::Filters::BaseFilter#apply
# File lib/datagrid/filters/date_filter.rb, line 7
def apply(grid_object, scope, value)
  if value.is_a?(Range)
    value = value.begin&.beginning_of_day..value.end&.end_of_day
  end
  super(grid_object, scope, value)
end
default_filter_where(scope, value) click to toggle source
# File lib/datagrid/filters/date_filter.rb, line 27
def default_filter_where(scope, value)
  if driver.is_timestamp?(scope, name)
    value = Datagrid::Utils.format_date_as_timestamp(value)
  end
  super(scope, value)
end
format(value) click to toggle source
Calls superclass method Datagrid::Filters::BaseFilter#format
# File lib/datagrid/filters/date_filter.rb, line 19
def format(value)
  if formats.any? && value
    value.strftime(formats.first)
  else
    super
  end
end
parse(value) click to toggle source
# File lib/datagrid/filters/date_filter.rb, line 14
def parse(value)
  Datagrid::Utils.parse_date(value)
end

Protected Instance Methods

formats() click to toggle source
# File lib/datagrid/filters/date_filter.rb, line 36
def formats
  Array(Datagrid.configuration.date_formats)
end