# Suggestions for a date picker that supports mm/yyyy

**URL:** <https://www.ruby-forum.com/t/suggestions-for-a-date-picker-that-supports-mm-yyyy/79070>\
**Category:** Ruby\
**Created:** [December 12, 2006, 12:30am UTC](https://www.ruby-forum.com/t/suggestions-for-a-date-picker-that-supports-mm-yyyy/79070 "2006-12-12T00:30:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 12, 2006, 12:30am UTC](https://www.ruby-forum.com/t/suggestions-for-a-date-picker-that-supports-mm-yyyy/79070/1 "2006-12-12T00:30:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 12, 2006, 12:40am UTC](https://www.ruby-forum.com/t/suggestions-for-a-date-picker-that-supports-mm-yyyy/79070/2 "2006-12-12T00:40:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 12, 2006, 1:34am UTC](https://www.ruby-forum.com/t/suggestions-for-a-date-picker-that-supports-mm-yyyy/79070/3 "2006-12-12T01:34:51Z")

</div>

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.
