Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Suggestions for a date picker that supports mm/yyyy
Gavin Kistner
12/11/2006 11:50:00 PM
From: Jason Vogel [mailto:jasonvogel@gmail.com]
> 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/rubyon...
> 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
1 Answer
Jason Vogel
12/12/2006 4:28:00 AM
0
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
On Dec 11, 5:49 pm, "Gavin Kistner" <gavin.kist...@anark.com> wrote:
> From: Jason Vogel [mailto:jasonvo...@gmail.com]
>
> > 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/rubyon...
>
> > 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
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Suggestions for a date picker that supports mm/yyyy
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password