Skip to content

Instantly share code, notes, and snippets.

@watzon
Created December 25, 2015 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watzon/425f8072e4d57c19a08f to your computer and use it in GitHub Desktop.
Save watzon/425f8072e4d57c19a08f to your computer and use it in GitHub Desktop.
Take ruby date range and see if any values from an array match values in the range
require 'date'
range = (Date.today-7)..(Date.today)
dates = ['2015-12-02','2015-12-03','2015-12-14','2015-12-19','2015-12-21','2015-12-23']
dates.each do |date|
date = Date.parse(date)
if range.include?(date)
puts date
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment