0

I'm trying to create a textbox that accepts mm/yy. For some reason this doesn't like dates beyond 2032. Can anyone tell me why not and what the solution is?

Update: Problem appears to be strictly a 2 digit year issue.

<input type="text" class="miniTextBox" id="${id}_Date" name="${id}_Date" maxlength="5"
 data-dojo-attach-point="indate"
 data-dojo-type="dijit/form/DateTextBox"  
 data-dojo-props="constraints:{fullYear: false, datePattern: 'MM/yy', max: '2099-12-31'},
 popupClass: 'dojox.widget.MonthAndYearlyCalendar'" 
 promptMessage="Example: 10/14" />

If it makes any difference, the following information may be helpful:

  • Uses Dojo 1.8
  • This is part of a widget template
  • There is a postCreate modification on this widget to set the fullYear constraint to false.
  • It does not use the standard popup calendar, and it doesn't matter if the date is entered by the popup or from the textbox.
  • the problem appears to be strictly a 2 digit year format issue - it works fine when the date format is changed to MM/yyyy and fullYear is true.
vogomatix
  • 4,856
  • 2
  • 23
  • 46
  • I tried this in http://jsfiddle.net/psoares/pMD3S/ and don't see the problem. What is your browser locale ? – Philippe Aug 01 '13 at 18:48
  • en - GMT+1:00 I think the problem may lie in the fact that your widget doesn't set the date to 2 digit year representation - I'll amend your jsFiddle tomorrow to demonstrate the problem better. – vogomatix Aug 01 '13 at 22:53

1 Answers1

1

In case anyone is still wondering, this is expected behavior. See documentation.

When two digit years are used, a century is chosen according to a sliding window of 80 years before and 20 years after present year, for both yy and yyyy patterns.

2033 was just outside that window in 2013 and 33 was interpreted as 1933.

user2075606
  • 173
  • 1
  • 8
  • I'm grateful you visited a question that I'd forgotten about :). I was working for a financial institution at the time and probably wanted only future dates for that particular datepicker instance. – vogomatix Dec 09 '15 at 12:14