views:

58

answers:

2

Hello,

I am trying to make a validation that will validate that the entered date is in future and that the selected date is in the next 7 days.

In order to validate if the date is in future I use;

valid_until.future? 

and this one works fine, but to make a validation to check if the date selected is withing 7 days from now?

+2  A: 
valid_until.future? && valid_until < 7.days.since(Time.now).to_date
neutrino
I am getting "comparison of Date with Time failed"
Adnan
see edited answer
neutrino
thank you @neutrino
Adnan
A: 

d = Date.new(2007, 8, 23)

=> Thu, 23 Aug 2007

?> nextweek = d + 7

=> Thu, 30 Aug 2007

so you can do it:

puts "hallo" if selected_date == selected_date + 7

VP