Re: Suggestions for a date picker that supports mm/yyyy

From: Jason V. [mailto:[email protected]]

Sent: Monday, December 11, 2006 4:30 PM
To: ruby-talk ML
Subject: Suggestions for a date picker that supports mm/yyyy

Does anyone have some suggestions for a date picker that supports
mm/yyyy.

Er, under what UI? Text/console? WxRuby? RubyCocoa? Rails?

Under the guess that you’re confusing “Ruby, the Language” with “Ruby on
Rails, the Web Framework that happens to be implemented using Ruby”, you
might want to re-ask your question on the Ruby on Rails group:
http://groups.google.com/group/rubyonrails-talk

Also, does anyone know the “best” way to validate a mm/yyyy
as “valid”? Meaning this month or the future?

How about this hack that probably fails near the last day of the month:

require ‘date’
d1 = “12/2006”
d2 = “13/2007”
d3 = “10/2005”
d4 = “11/2006”
d5 = “12/2006”

[d1,d2,d3,d4,d5].each{ |datestring|
begin
d = Date.strptime( “28 #{datestring}”, ‘%d %m/%Y’ )
raise if d < Date.today
puts “OK: #{d}”
rescue
puts “BAD DATE: #{datestring}”
end
}

#=> OK: 2006-12-28
#=> BAD DATE: 13/2007
#=> BAD DATE: 10/2005
#=> BAD DATE: 11/2006
#=> OK: 2006-12-28

Sorry, I definitely should have been clearer.

Under Rails I was also thinking Javascript/Ajax (technically). I’ll
ask over in the RoR group too.

I asked the question here because I was thinking the validation would
be in Ruby.

Thanks Paul and Gavin,
Jason