Does anyone have some suggestions for a date picker that supports
mm/yyyy.
Also, does anyone know the “best” way to validate a mm/yyyy as “valid”?
Meaning this month or the future?
Thanks,
Jason
Does anyone have some suggestions for a date picker that supports
mm/yyyy.
Also, does anyone know the “best” way to validate a mm/yyyy as “valid”?
Meaning this month or the future?
Thanks,
Jason
Jason Vogel wrote:
Does anyone have some suggestions for a date picker that supports
mm/yyyy.
Do you mean a GUI component?
Also, does anyone know the “best” way to validate a mm/yyyy as “valid”?
Meaning this month or the future?
Test the entered month and year to see if they are >= the present month
and
year? You cold do this by adding the present year * 12 to the present
month, this gives you an easily compared integer with units of months.
Do
the same to the user’s entry and there you are.
If you include days and require the resolution of days, things become
more
complicated, but for the case of month and year, it is rather easy.
On Dec 11, 2006, at 5:30 PM, Jason V. wrote:
Does anyone have some suggestions for a date picker that supports
mm/yyyy.Also, does anyone know the “best” way to validate a mm/yyyy as
“valid”?
Meaning this month or the future?
Not sure exactly what validation you are doing with month and year.
Maybe
you mean mm/dd/yyyy?
But, FYI, you can probably validate dates without too much effort
since there are only 14 calendars.
One for Jan 1 on each day of the week, and another similar seven
calendars,
except that the year is a leap year.
Leap years are yyyy % 4 == 0. This tells you which of the two
calendars to
choose, assuming you know what day Jan 1 falls on.
To get that, pick a starting point and see that Jan 1 moves forward
one day
for each year, and two days for the year following a leap year.
2000 - Sat
2001 - Mon
2002 - Tue
2003 - Wed
2004 - Thu
2005 - Sat
2006 - Sun
2007 - Mon
HTH
…
Jim F.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs