Skip to content

Time value should be modified when comparing dates #19

@emolayi

Description

@emolayi

When comparing dates, the time value needs to be modified to include any DateTimes spanning the 24 hour covered by that date value. Set date to end_of_day for lteq comparisons, and to beginning_of_day for gteq values:

# Override ActionSet filter_instructions_for method to modify filtering behavior.
  def filter_instructions_for(set)
    filter_params_hash = super

    # Modify dates passed to lteq and gteq matchers so that their time portion is set correctly
    filter_params_hash.select { |_, v| v.instance_of?(ActiveSupport::TimeWithZone) }.each do |k, v|
      filter_params_hash[k] = v.end_of_day if k.first.include? 'lteq'
      filter_params_hash[k] = v.beginning_of_day if k.first.include? 'gteq'
    end

    filter_params_hash
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions