Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time value should be modified when comparing dates #19

Open
emolayi opened this issue Jan 2, 2019 · 1 comment
Open

Time value should be modified when comparing dates #19

emolayi opened this issue Jan 2, 2019 · 1 comment

Comments

@emolayi
Copy link
Contributor

emolayi commented Jan 2, 2019

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
@fractaledmind
Copy link
Owner

@emolayi or @riyengar8: Can you write a test (in ActiveSet) that captures the failure condition for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants